Jump to content

How is this possible?


lxndr

Recommended Posts

I have a situation regarding an SQL update which I really can't make any sense of at all.  I'm executing the following call to MySQL:

 

$sql = "UPDATE arcade_lp SET game_name = '$game_name',  game_id = '$game_id', date = '$today', user = '$user_name', popup = '$popup'  WHERE user = '$user_name'  ";

if ($user_name == "admin") echo "debug:  $sql<br>";

$result = mysql_query($sql, $db)  or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error());

 

The debug from above shows the following

 

debug:  UPDATE arcade_lp SET game_name = 'klax3dEasyJS', game_id = '273', date = '1180010641', user = 'MikeL', popup = '0' WHERE user = 'MikeL'

 

Yet following the above MySQL transaction the actual database contains:

 

game_name:  blank

game_id:  0

date:  "contains previous value, i.e. not updated

popup: 1

 

How is this possible ????

 

..

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/52802-how-is-this-possible/
Share on other sites

As gameid, date and popup are int's shouldn't you NOT have quotes around them ?

 

I can't recall whether mysql cares during syntax.

 

I've changed the code and removed the quotes but the problem still remains.  Contrary to my original post it does appear that the date field updates but the game_id is still 0, the game_name is blank and the popup value is 1 instead of 0 ?

 

Link to comment
https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260841
Share on other sites

You need to give the details about your table structure.

 

game_name: varchar(35)

game_id: int(4)

date: int(11)

user: varchar(45)

popup: tinyint(1)

 

You are not supposed to give quotes for integer data type.

 

I've changed that and removed the quotes and the problem is still there.  I should also say that this problem only occurs in relation to 2 of the game_ids ... the other 271 don't cause this problem.

 

Link to comment
https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260851
Share on other sites

Try using CUI if it works fine then you need to look into your PHP code ,like triming the variables before using them in query.

 

If I take the debug statement which is the actual SQL call made by my php program and copy/paste it into the SQL tab of phpmyadmin it works perfectly so I can't see how the code can be at fault ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260897
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.