MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old June 26th, 2004, 12:43 PM
Malace Malace is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 Malace User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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...



Reply With Quote
  #2  
Old June 26th, 2004, 12:47 PM
mughrabi mughrabi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 mughrabi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try this
$query = "UPDATE km_users SET health = \"".$newhealth."\" WHERE ID = '$ID'"; //


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > my update query fails to update.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway