Web Hosting Talk







View Full Version : been trying..


brcolow
04-01-2003, 11:27 PM
I have been trying to fix this on my own for probably 3 days now and still it does not work. I am trying to set it so when user_hp is at 0, it sets alot of other variables to 0 as you will see in this script...

if ($urow['user_hp'] == '0')
{
$amount = "1";
$sql = "UPDATE " . USERS_TABLE . " SET user_enemy = '0' WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

$sql = "UPDATE " . USERS_TABLE . " SET user_turn = '0' WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

$sql = "UPDATE " . USERS_TABLE . " SET battle_message = ' ' WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

$sql = "UPDATE " . USERS_TABLE . " SET user_challenge = '0' WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

$sql = "UPDATE " . USERS_TABLE . " SET user_wins = user_wins + $amount WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

print"You have won the battle!";
die();
}

Now, that gives me this error...
Unknown column 'mvllallstar' in 'where clause'
mvllallstar of course being the username, but it doesnt make sense ecspecially because this works in a part just a little down from this code in the same script...

$sql = "UPDATE " . USERS_TABLE . " SET user_hp = $damageresult WHERE username = '$urow[username]'";
$result = mysql_query($sql) or die(mysql_error());

Does that make any sense whatsoever!?

Tweakin
04-02-2003, 08:28 AM
What is USERS_TABLE? Is it defined above with define()? Other then that and that odd call to die() after the first block of code (look into exit; .. ) I don't see any mistakes. This leads to the conclusion either your SQL is inaccurate as to the actual tables, or there is an error in your code else where in the script.

ain't debugging a pain? Good Luck

W-H-Mtl
04-02-2003, 02:12 PM
My first impression when I see all your sql statements is:
what is $urow?
is it an array?
is it a db recordset?

$urow['user_hp'], I understand.
$urow[username], i don't. Maybe the error stems from this.
Could you actually be meaning $urow['username']?

Also, I read that you've spent 3 days on this...
I've done that too, so I'll give you a life saving fix for you problem:

Print out the sql statement before you execute it (for debugging purposes).
Programming is a little like magic, so are bugs.
I've often asked myself: How did I generate THAT?

Hope this helps.