Jump to content

Q695

Members
  • Posts

    783
  • Joined

  • Last visited

Everything posted by Q695

  1. Use this video: http://www.youtube.com/watch?v=ScXN5mKFtiw
  2. It would be like an accountant totaling columns, not simple counting.
  3. A nice addition would be a code runner that asks for the values of any unassigned variables.
  4. do a simple math conversion on the price, then output it by multiplying the conversion rate.
  5. work through the videos by this buy that pertain to what you're doing, starting with: http://www.youtube.com/watch?v=T0Uv3VeTMR8
  6. Does anyone know how to total identical values in arrays easily? I tried the following, and none did what I needed: //echo "$sql_merge_stats<br>"; print_r($row_merge_stats); $total=array_merge($row_merge_stats); echo "<p>"; print_r($total); ///////////// echo "<p>"; $result_merge_stats = mysql_query($sql_merge_stats, $con) or die ("can not generate result " . mysql_error()); while ($row_merge_stats = mysql_fetch_assoc($result_merge_stats)){ print_r($row_merge_stats); echo "<br>"; ///////////////// $total=$total+$row_merge_stats; } echo "<br>"; print_r($total); //erroring $result_merge_stats = mysql_query($sql_merge_stats, $con) or die ("can not generate result " . mysql_error()); //$row_merge_stats = mysql_fetch_assoc($result_merge_stats); $sumArray = array(); foreach (mysql_fetch_assoc($result_merge_stats) as $k=>$subArray) { foreach ($subArray as $id=>$value) { $sumArray[$id]+=$value; } } print_r($sumArray); the output is: Array ( [__] => 1 [______] => 1 [___] => 1 [_______] => 1 ) Array ( [__] => 1 [______] => 1 [_____] => 1 [_____] => 1 ) Array ( [__] => 1 [______] => 1 [_____] => 1 [_____] => 1 ) Array ( [__] => 1 [_____] => 2 [_______] => 7 [_____] => 2 ) Array ( [__] => 1 [______] => 1 [______] => 1 [_____] => 1 )
  7. I'm turning it into a 100% td width like a chat room.
  8. Does anyone know how to force a long string a user may enter to be broken into parts on different lines? to see what I mean visit this code: http://jsfiddle.net/Q695/XJSQU/
  9. This guy taught me how to do an image upload script with his videos: http://www.youtube.com/watch?v=T0Uv3VeTMR8 That's all the help I can provide you.
  10. You don't change PHP font as PHP is server side, you change CSS/HTML font. If this is a captcha, you want to do it with a font included somewhere on your website.
  11. Yes, run it through an if isset else to set the variable, because if you do it without the value it may create an error.
  12. I originally tried doing the select with a function, but it failed, and wrote selected where the function was placed in the document.
  13. for some reason I had to reenter the page.
  14. I know the PHP is correct, but the HTML is adding extra information, and it's not pulling up the selected information based on the statement set. <select name="slot" size="1"> <option value="" <?php if ($item_slot=="0"){ echo "selected";} ?>>Pick One</option> <option value="1"<?php if ($item_slot=="1"){ echo "selected";} ?>>Amulet</option> <option value="2"<?php if ($item_slot=="2"){ echo "selected";} ?>>Head Gear</option> <option value="3"<?php if ($item_slot=="3"){ echo "selected";} ?>>Epaulets</option> <option value="4"<?php if ($item_slot=="4"){ echo "selected";} ?>>Shield</option> <option value="5"<?php if ($item_slot=="5"){ echo "selected";} ?>>Chest Gear</option> <option value="6"<?php if ($item_slot=="6"){ echo "selected";} ?>>Weapon</option> <option value="7"<?php if ($item_slot=="7"){ echo "selected";} ?>>Ring</option> <option value="8"<?php if ($item_slot=="8"){ echo "selected";} ?>>Boots</option> <option value="9"<?php if ($item_slot=="9"){ echo "selected";} ?>>Gloves</option> <option value="10"<?php if ($item_slot=="10"){ echo "selected";} ?> >Backpack</option> </select> output code <select size="1" name="slot"> <option value="">Pick One</option> <option value="1">Amulet</option> <option selected="" value="2">Head Gear</option> <option value="3">Epaulets</option> <option value="4">Shield</option> <option value="5">Chest Gear</option> <option value="6">Weapon</option> <option value="7">Ring</option> <option value="8">Boots</option> <option value="9">Gloves</option> <option value="10">Backpack</option> </select>
  15. Why was it the double equals that time, but the previous time it was the single equals?
  16. How would I write the following if statement properly to make sure there aren't any errors with the file?
  17. Where can I find the hall of shame for responses?
  18. Should be a global, not a return
  19. I checked the function return when it was erroring the first time, but i'll try again.
  20. inside function: echo "<br>random path: $path_rand"; return $path_rand; outside function: echo "<p>random path2: $path_rand"; $path_rand is echo in the function, but for some reason not being posted outside of the function. Why? I tried the following simple script: function test(){ $i=2; return $i; } test(); echo "X:$i"; got back: Notice: Undefined variable: in ______ on line X(echo line) X:
  21. try echo $sqlinsert; you forgot the e-mail variable on the insert.
  22. I always copy my get variable from my print_r ($_GET);
  23. I didn't realize there was an intro forum, sorry.
  24. I'm thinking I should try rewriting it from step 1, because many things are working, but some seem screwed up. Below is the code, but now it's not naming the image, or uploading it after I tried fixing it: image uploader <?php //$path folder of location being uploaded to on recieving page //$path full path of image //$table_name name of table being checked //$var_check name of variable in table //$path_rand image path in directory //$user primary criteria //$id criteria item //$limitor secondary criteria //$item secondary criteria item //$picture picture item name if ($_FILES['creature_image']['error']=0){ // loads image variables $name = $_FILES['creature_image']['name']; $temp = $_FILES['creature_image']['tmp_name']; $type = $_FILES['creature_image']['type']; $size = $_FILES['creature_image']['size']; //size of uploaded image $img_size = getimagesize( $temp ); $width= $img_size[0]; $height= $img_size[1]; //requirements $maxwidth = 1280; $maxheight = 1280; $maxsize= 1048576; $allowed = array('image/jpeg' , 'image/png' , 'image/gif'); //revisions $new_width=300; $new_height=300; if (in_array($type, $allowed)){ if ( empty($_GET['creature']) ){ $m=0; while ($m <= 100) { //random charicter generator $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < 64; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } $path_rand = $randomString; $sql_img_test= "SELECT * FROM $table_name WHERE $var_check='$path_rand' limit 1"; $result_img = mysql_query($sql_img_test, $con) or die ("can not generate result " . mysql_error()); $row_img = mysql_fetch_assoc($result_img); if (!$row_img){ $m=101; } else { $m++; } //end of new entry } } else { $sql_img_test= "SELECT * FROM $table_name WHERE $user='$id' && $limitor=$item limit 1"; $result_img = mysql_query($sql_img_test, $con) or die ("can not generate result " . mysql_error()); $row_img = mysql_fetch_assoc($result_img); $path_rand=$row_img[$picture]; echo "image updated"; } } //image load path $path= "$path$path_rand.jpg"; //echo $path; // uploading file, and create database entry move_uploaded_file($temp,$path); //places image in file location } else { echo "Image not uploaded."; } ?> the database inserter: <?php $path="images/new_creatures/ "; $table_name="creature_create"; $var_check= "picture"; $user = 'user'; //$id = '$id'; $limitor = 'creature_id'; $picture='picture'; if (isset($_GET['creature'])){ $item = $_GET['creature']; } if ( isset($_POST['creature_name']) && isset($_FILES['creature_image']) && isset($_POST['def_rate']) && isset($_POST['def_rate_range']) && isset($_POST['att_rate']) && isset($_POST['att_rate_range']) && isset($_POST['def']) && isset($_POST['def_range']) && isset($_POST['att']) && isset($_POST['att_range']) && isset($_POST['health']) && isset($_POST['health_range']) ){ include "image_upload.php"; $name = $_POST['creature_name']; //$image = $path_rand; $def_rate = $_POST['def_rate']; $def_rate_range=$_POST['def_rate_range']; $att_rate=$_POST['att_rate']; $att_rate_range=$_POST['att_rate_range']; $def=$_POST['def']; $def_range=$_POST['def_range']; $att=$_POST['att']; $att_range=$_POST['att_range']; $health=$_POST['health']; $health_range=$_POST['health_range']; if( empty($_GET['creture'])){ echo "empty"; $sql_new_creature="INSERT INTO creature_create (`user`, `name`, `def_rate`, `def_rate_dif`, `att_rate`, `att_rate_dif`, `def`, `def_dif`, `att`, `att_dif`, `health`, `health_dif`) VALUES ('$id', '$name', '$def_rate', '$def_rate_range', '$att_rate', '$att_rate_range', '$def', '$def_range', '$att', '$att_range', '$health', '$health_range');"; //echo $sql_new_creature; $sql_creature = "SELECT * FROM `creature_create` WHERE user=$id LIMIT 1"; $result_creature = mysql_query($sql_creature, $con) or die ("can not generate result " . mysql_error()); $row_creature = mysql_fetch_assoc($result_creature); $path_rand=$row_creature['picture']; } else if( isset($_GET['creture'])){ // echo "set"; $creature=$_GET['creture']; $sql_new_creature=" UPDATE creature_create SET `name` = '$name', `def_rate` = '$def_rate', `def_rate_dif` = '$def_rate_range', `att_rate` = '$att_rate', `att_rate_dif` = '$att_rate_range', `def` = '$def', `def_dif` = '$def_range', `att` = '$att', `att_dif` = '$att_range', `health` = '$health', `health_dif` = '$health_range' WHERE `creature_id` = '$creature'; "; /*$sql_creature = "SELECT * FROM `creature_create` WHERE user=$id LIMIT 1"; $result_creature = mysql_query($sql_creature, $con) or die ("can not generate result " . mysql_error()); $row_creature = mysql_fetch_assoc($result_creature); */ $path_rand=$row_creature['picture']; //echo $sql_new_creature; } } else { echo "error"; $sql_creature = "SELECT * FROM `creature_create` WHERE user=$id LIMIT 1"; $result_creature = mysql_query($sql_creature, $con) or die ("can not generate result " . mysql_error()); $row_creature = mysql_fetch_assoc($result_creature); $path_rand=$row_creature['picture']; } $result = mysql_query($sql_new_creature, $con) or die ("can not generate result " . mysql_error()); $def_rate_max=$def_rate+$def_rate_range; $att_rate_max=$att_rate+$att_rate_range; $def_max=$def+$def_range; $att_max=$att+$att_range; echo" <table width='100%' border='1' cellspacing='0' cellpadding='0'> <tr> <td align='center' colspan='2'> <h1>$name</h1> <br> <img src='images/new_creatures/ $path_rand.jpg' width='200' height='200'> </td> </tr> <tr> <td>Attack Rate: $att_rate - $att_rate_max</td> <td>Defense Rate: $def_rate - $def_rate_max</td> </tr> <tr> <td>Attack: $att - $att_max</td> <td>Defense: $def - $def_max</td> </tr> </table> "; ?> It will upload/rewrite an image/content for user added content before a submission for a suggested addition to a game.
  25. menu 1 needs to target menu 2 with javascript/request....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.