|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
my update query fails to update.
<?php // slaying monster module
include 'connect.php'; session_start( ); if ( isset( $_SESSION['player'])) { $player =$_SESSION['player']; $playerstats1 ="SELECT * from km_users where playername='$player'"; $playerstats2 =mysql_query($playerstats1) or die ("Could not find player"); $playerstats3 =mysql_fetch_array($playerstats2); if ( $playerstats3[foodsupply] <= 10) { Print " your food supply is too low to feed upon, you cannot eliminate your population without eliminating yourself as well."; } else if ( $playerstats3[health] >= $playerstats3[maxhp]) { $playerstats3[health] =$playerstats3[maxhp]; Print "You are full, you feel no urge to hunt"; } else if ( $playerstats3[health] < $playerstats3[maxhp]) { $foodsupply =$playerstats3[foodsupply]*.10; $randomnum =rand(0,$foodsupply); $newhealth =$playerstats3[health]+$randomnum; $aftermath =$playerstats3[foodsupply]-$randomnum;// setup MySQL query $query = "UPDATE km_users SET health = '$newhealth' WHERE ID = '$ID'"; // // Execute Query $result = mysql_query($query) or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ()); // setup MySQL query $query = "UPDATE km_users SET foodsupply = '$aftermath' WHERE ID = '$ID'"; // // Execute Query $result = mysql_query($query) or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ()); print " <A href='index.php'>Go back to main</a>."; Print "You now have a population of $aftermath. And now have $newhealth hitpoints."; } } else { Print "you are not logged in."; } ?> The script works fine, and reports no errors in updating the data, the output screen looks like this. Go back to main.You now have a population of 199. And now have 1 hitpoints. I'm really stuck on why the script wont update the table... |
|
#2
|
|||
|
|||
|
try this
$query = "UPDATE km_users SET health = \"".$newhealth."\" WHERE ID = '$ID'"; // |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > my update query fails to update. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|