lxndr Posted May 24, 2007 Share Posted May 24, 2007 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 ???? .. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/ Share on other sites More sharing options...
ashishmat1979 Posted May 24, 2007 Share Posted May 24, 2007 Only thing seems to happen may be that value you are updating for $user_name i.e "MikeL" is misspelled by you; please check again if it exists in table. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260687 Share on other sites More sharing options...
Illusion Posted May 24, 2007 Share Posted May 24, 2007 You need to give the details about your table structure. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260734 Share on other sites More sharing options...
lxndr Posted May 24, 2007 Author Share Posted May 24, 2007 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) Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260761 Share on other sites More sharing options...
Bok Posted May 24, 2007 Share Posted May 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260771 Share on other sites More sharing options...
lxndr Posted May 24, 2007 Author Share Posted May 24, 2007 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260841 Share on other sites More sharing options...
Illusion Posted May 24, 2007 Share Posted May 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260844 Share on other sites More sharing options...
lxndr Posted May 24, 2007 Author Share Posted May 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260851 Share on other sites More sharing options...
Illusion Posted May 24, 2007 Share Posted May 24, 2007 Have you used any constraints on the table and one more thing I want to know is why do you want to update user still is using the same name for where clause in your query. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260854 Share on other sites More sharing options...
lxndr Posted May 24, 2007 Author Share Posted May 24, 2007 Have you used any constraints on the table and one more thing I want to know is why do you want to update user still is using the same name for where clause in your query. There are no constraints on the table and yes the "user" update is redundant ... Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260860 Share on other sites More sharing options...
Illusion Posted May 24, 2007 Share Posted May 24, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260880 Share on other sites More sharing options...
lxndr Posted May 24, 2007 Author Share Posted May 24, 2007 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/52802-how-is-this-possible/#findComment-260897 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.