ivoilic
Members-
Posts
38 -
Joined
-
Last visited
About ivoilic
- Birthday 11/25/1995
Profile Information
-
Gender
Male
-
Location
New York City
ivoilic's Achievements
Member (2/5)
0
Reputation
-
Thanks PaulRyan your code worked perfectly! @Pickachu2000 Don't worry the serials are saved to a database and the newly generated ones are checked against the db.
-
So I wrote this code to generate a 12 character long serial number looking something like this: 123a-34se-sdf3 I am new to php and really bad at using loops. If some one could explain to me some method of repeating the action rather than having to copy and paste. $ser_num = array("1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); $num1 = rand(0,count($ser_num)-1); $numf1 = wordwrap($ser_num[$num1],1,"\n", true); $num2 = rand(0,count($ser_num)-1); $numf2 = wordwrap($ser_num[$num2],1,"\n", true); $num3 = rand(0,count($ser_num)-1); $numf3 = wordwrap($ser_num[$num3],1,"\n", true); $num4 = rand(0,count($ser_num)-1); $numf4 = wordwrap($ser_num[$num4],1,"\n", true); $num5 = rand(0,count($ser_num)-1); $numf5 = wordwrap($ser_num[$num5],1,"\n", true); $num6 = rand(0,count($ser_num)-1); $numf6 = wordwrap($ser_num[$num6],1,"\n", true); $num7 = rand(0,count($ser_num)-1); $numf7 = wordwrap($ser_num[$num7],1,"\n", true); $num8 = rand(0,count($ser_num)-1); $numf8 = wordwrap($ser_num[$num8],1,"\n", true); $num9 = rand(0,count($ser_num)-1); $numf9 = wordwrap($ser_num[$num9],1,"\n", true); $num10 = rand(0,count($ser_num)-1); $numf10 = wordwrap($ser_num[$num10],1,"\n", true); $num11 = rand(0,count($ser_num)-1); $numf11 = wordwrap($ser_num[$num11],1,"\n", true); $num12 = rand(0,count($ser_num)-1); $numf12 = wordwrap($ser_num[$num12],1,"\n", true); $serial = ''.$numf1.''.$numf2.''.$numf3.''.$numf4.'-'.$numf5.''.$numf6.''.$numf7.''.$numf8.'-'.$numf9.''.$numf10.''.$numf11.''.$numf12.'';
-
Yeah problem solved i modified to the example you gave me to this: http://jsfiddle.net/kKNNE/14/ It's exactly what I need! THANKS!
-
So I have a series of textboxes and when any of the values are changed I want JS to apply some basic calculations to each and then display the sum. I can do this where it detects the change in one textbox, but I am not sure how to get it to detect a change in any of the textboxes other than copy and pasting the code and changing the id for each. $(document).ready(function()//When the dom is ready { $("#def").keyup(function() { //if theres a change in var def = $("#def").val(); var acc = $("#acc").val(); //Calculate Each Cost var def_cost = def * 5; var acc_cost = acc * 5; //Total Costs var points= Number(acc_cost) + Number(def_cost); //Display Costs in Span $("#pointspreview").html(points); }) });
-
Thanks scootstah you solution worked perfectly!
-
Hi I relatively new to PHP and I am having trouble solving this problem: I want to take the number the user has given and then enter it in this equation 100/(2^X). I can do this easily. However I also need to apply the same equation to every number less than the given (If the user enters 4 it must by applied to 3,2,1 as well) I can generate a list of numbers using the range() function: foreach (range(0, $users_number) as $number) { echo $number; } However I can't figure out how to apply the equation to each number. The next step is to get the total sum but given the values of the the others that's pretty easy.
-
Let me clarify the file is being saved as $serial$title.png. $serial is not a folder. There is no problem with that part of the code. The image gets saved but does no appear in the browser.
-
So I am trying to generate an image based off of a form filled out by the user. It generates the image which is saved to a folder but the image does not show up in the browser. However when I comment out the header there are no errors! Here is the message I get: "The Image: 'http:// localhost/whatever.php' cannot be displayed because it contains errors. Here is all of the code I included it all because I have no clue what is causing it. <?php require 'connect.inc.php'; require 'core.inc.php'; //Get all info from cardcrafter.php $title = $_REQUEST['title'] ; /* $desc = $_REQUEST['desc'] ; */ $cardart = $_REQUEST['cardart'] ; $atk = $_REQUEST['atk']; $def = $_REQUEST['def']; $acc = $_REQUEST['acc']; $hp = $_REQUEST['hp']; //$quo = ($desc == "") ? "" : "\""; //Serial Number Generation (Needs to be shortned with a function) $ser_num = array("1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); $num1 = rand(0,count($ser_num)-1); $numf1 = wordwrap($ser_num[$num1],1,"\n", true); $num2 = rand(0,count($ser_num)-1); $numf2 = wordwrap($ser_num[$num2],1,"\n", true); $num3 = rand(0,count($ser_num)-1); $numf3 = wordwrap($ser_num[$num3],1,"\n", true); $num4 = rand(0,count($ser_num)-1); $numf4 = wordwrap($ser_num[$num4],1,"\n", true); $num5 = rand(0,count($ser_num)-1); $numf5 = wordwrap($ser_num[$num5],1,"\n", true); $num6 = rand(0,count($ser_num)-1); $numf6 = wordwrap($ser_num[$num6],1,"\n", true); $num7 = rand(0,count($ser_num)-1); $numf7 = wordwrap($ser_num[$num7],1,"\n", true); $num8 = rand(0,count($ser_num)-1); $numf8 = wordwrap($ser_num[$num8],1,"\n", true); $num9 = rand(0,count($ser_num)-1); $numf9 = wordwrap($ser_num[$num9],1,"\n", true); $num10 = rand(0,count($ser_num)-1); $numf10 = wordwrap($ser_num[$num10],1,"\n", true); $num11 = rand(0,count($ser_num)-1); $numf11 = wordwrap($ser_num[$num11],1,"\n", true); $num12 = rand(0,count($ser_num)-1); $numf12 = wordwrap($ser_num[$num12],1,"\n", true); $serial = ''.$numf1.''.$numf2.''.$numf3.''.$numf4.'-'.$numf5.''.$numf6.''.$numf7.''.$numf8.'-'.$numf9.''.$numf10.''.$numf11.''.$numf12.''; //$serial = '569B-U31Z-QOKW'; // array of random abilites (No longer needed for now) //$ability = array("When $title is spawned draw a card", "Any card damaged by $title is delt 1 damage every turn"); // generate a random number with range of # of array elements //$pos = rand(0,count($ability)-1); // get the ability and word wrap it //$ability_f = wordwrap($ability[$pos],40,"\n", true); $query="SELECT `serial` FROM `Cards` WHERE `serial`='$serial'"; $query_run=mysql_query($query); if(mysql_num_rows($query_run)>=1) { header('Location: cardcrafter.php'); } else { if ($title == ""){echo "Your card needs a name!";} else {if ($atk <=0 || $def <=0 || $acc <=0 || $hp <= 0) {echo "All skills need at least one skill point!";} else { //Calculate total points $points = $atk + $def + $acc + $hp; $user_id = getuserfield('id'); $username = getuserfield('username'); $query = "INSERT INTO `Cards` VALUES ('','".mysql_real_escape_string($user_id)."','".mysql_real_escape_string($title)."','".mysql_real_escape_string($cardart)."','".mysql_real_escape_string($serial)."','".mysql_real_escape_string($atk)."','".mysql_real_escape_string($def)."','".mysql_real_escape_string($acc)."','".mysql_real_escape_string($hp)."','".mysql_real_escape_string($username)."','')"; if($query_run = mysql_query($query)) { } else { echo mysql_error(); } // Load Template $image = imagecreatefrompng ( "../Card_Images/water.png" ); $filename = "../Art/eyebook.jpg"; // get new dimensions list($width, $height) = getimagesize($filename); $new_width = "638"; $new_height = "450"; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $art = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $art, 0, 0, 0, 0, $new_width, $new_height, $width, $height); //Merge Background with card art imagecopymerge($image, $image_p, 60, 130, 0, 0, 638, 450, 100); // Path to our font file $font = '../Joanna/MJoa'; $italic = '../Joanna/MJoaIta'; // pick color for the text $fontcolor = imagecolorallocate($image, 0, 0, 0); //Create Title imagettfbbox(35, 0, $font, $title); imagettftext($image, 35, 0, 40, 80, $fontcolor, $font, stripslashes($title)); //Create Description /*imagettfbbox(30, 0, $italic, $desc); imagettftext($image, 30, 0, 70, 700, $fontcolor, $italic, stripslashes(" $quo$desc$quo "));*/ //Create Ability (Not used as of game V3) //imagettfbbox(25, 0, $font, $ability_f); //imagettftext($image, 25, 0, 70, 700, $fontcolor, $font, stripslashes($ability_f)); //Points imagettfbbox(35, 0, $font, $points); imagettftext($image, 35, 0, 585, 80, $fontcolor, $font, $points); //HP imagettfbbox(50, 0, $font, $hp); imagettftext($image, 50, 0, 40, 1000, $fontcolor, $font, $hp); //Attack imagettfbbox(30, 0, $font, $atk); imagettftext($image, 30, 0, 150, 635, $fontcolor, $font, $atk); //Defense imagettfbbox(30, 0, $font, $def); imagettftext($image, 30, 0, 360, 635, $fontcolor, $font, $def); //Accuracy imagettfbbox(30, 0, $font, $acc); imagettftext($image, 30, 0, 560, 635, $fontcolor, $font, $acc); //Serial imagettfbbox(25, 0, $font, $serial); imagettftext($image, 25, 0, 150, 1000, $fontcolor, $font, stripslashes($serial)); // get new dimensions $imagewidth = 754; $imageheight = 1054; $final_width = "251"; $final_height = "351"; // Resample $image_f = imagecreatetruecolor($final_width, $final_height); imagecopyresampled($image_f, $image, 0, 0, 0, 0, $final_width, $final_height, $imagewidth, $imageheight); // output image to the browser header('Content-type: image/png'); imagepng($image_f, '../Cards/'.$serial.''.$title.'.png'); // delete the image resource imagedestroy($image); imagedestroy($art); imagedestroy($image_p); imagedestroy($image_f); }}} ?>
-
So I have this function which generates a random serial # that is 12 characters long. However I want to insert a dash every four characters like so: XXXX-XXXX-XXXX Any suggestions? <?php $serial1 = get_serial_num(12); //Serial # function function get_serial_num($number_cnt){ $ret_arr = array(); $serial = ""; $ser_num = array("1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); for($i = 0; $i < $number_cnt; $i++){ $rand = rand(0,count($ser_num)-1); $val = wordwrap($ser_num[$rand],1,"\n", true); $serial .= $val; } return $serial; } echo ''.$serial1.''; ?> Warning: I am a bit noobish.
-
I tried your script and it did not work however I found this plug-in: http://www.mathachew.com/sandbox/jquery-autotab/ So I ended up getting what I needed and some. Thanks for all your help.
-
Sorry for being a noob but I just tried to figure out how to do that and completely failed. Would you please clarify?
-
So I have code for three text-boxes in a form: <input type='text' name='serial1' style="width:40px;" maxlength="4"> - <input type='text' name='serial2' style="width:40px;" maxlength="4"> - <input type='text' name='serial3' style="width:40px;" maxlength="4"> What I want to know is if there is anyway to make it so that after the user has typed the max # of characters in the first text box the cursor will automatically move to the next text-box.
-
YES it worked! Thanks so much. If it's not to much trouble can you tell me why that actually worked.
-
sorry i'm pretty new at this can you clarify
-
Ok so I have a form to submits to a .php file that creates an image. This works fine, but I also want the info from the form to be sent to MySQL database. The problem is that something in a script I "required" called core.inc.php is interfering and so no image is output. Here is core.inc.php: <?php ob_start(); session_start(); $current_file = $_SERVER['SCRIPT_NAME']; if(isset($_SERVER['HTTP_REFERER'])&&!empty($_SERVER['HTTP_REFERER'])) { $http_referer = $_SERVER['HTTP_REFERER']; } function loggedin() { if(isset($_SESSION['user_id'])&&!empty($_SESSION['user_id'])) { return true; } else { return false; } } function getuserfield($field) { $query="SELECT `$field` FROM `Users` WHERE `id`='".$_SESSION['user_id']."'"; if($query_run=mysql_query($query)) { if($query_result = mysql_result($query_run, 0, $field)) { return $query_result; } } } ?> Here is the code for the image creating .php file: <?php require 'connect.inc.php'; require 'core.inc.php'; $title = $_REQUEST['title'] ; $user_id = getuserfield('id'); $query = "INSERT INTO `---` VALUES ('".mysql_real_escape_string($title)."','".mysql_real_escape_string($user_id)."')"; $query_run = mysql_query($query); //There is some more code in here obviously, but it's irrelevant header('Content-type: image/png'); imagepng($image_f); imagedestroy($image_f) Can anybody give me some idea of what is conflicting or what I can do to fix it?