gamefreak13 Posted May 23, 2008 Share Posted May 23, 2008 This is just ridiculous. This is sooooo simple and I can't figure it out. And yes "name" and "uname" are different. UPDATE mytable SET name='John', ip='68.10.721.209' WHERE uname='test' AND ip='68.10.721.209' My table (before running this query) contains user 68.11.21.2 Travis test 68.11.21.2 Jason test 68.10.721.209 Steve user 68.10.721.209 Mike My table (after running this query) contains user 68.11.21.2 Travis test 68.10.721.209 John test 68.10.721.209 John user 68.10.721.209 Mike My query is only respecting the "where uname = test" part. It doesn't care about the ip even though I told it to only update for that ip. Link to comment https://forums.phpfreaks.com/topic/106869-solved-update-two-rows-with-two-where-statements/ Share on other sites More sharing options...
gamefreak13 Posted May 23, 2008 Author Share Posted May 23, 2008 I think I just realized my problem... I don't need to set the ip again.. but that still shouldn't matter.. it should still only touch the rows where the uname / ip match... so there is still a problem. Link to comment https://forums.phpfreaks.com/topic/106869-solved-update-two-rows-with-two-where-statements/#findComment-547821 Share on other sites More sharing options...
unidox Posted May 23, 2008 Share Posted May 23, 2008 Try this: mysql_query("UPDATE `mytable` SET `name` = 'John', `ip` = '68.10.721.209' WHERE `uname` = 'test' && `ip` = '68.10.721.209'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/106869-solved-update-two-rows-with-two-where-statements/#findComment-547826 Share on other sites More sharing options...
gamefreak13 Posted May 23, 2008 Author Share Posted May 23, 2008 Thanks but it seems my error was I was missing a single quote ( the ' thing ) at the end. When I copied it in to the post I had copied it from a different text file which was correct, but when I copied it in to my script I missed the last single quote. Don't ya just hate it when the stupid little things drive you nuts? But while we have this thread.. are "AND" and "&&" the same thing? Link to comment https://forums.phpfreaks.com/topic/106869-solved-update-two-rows-with-two-where-statements/#findComment-547832 Share on other sites More sharing options...
unidox Posted May 23, 2008 Share Posted May 23, 2008 Yes, but I normally avoid errors by using &&. Link to comment https://forums.phpfreaks.com/topic/106869-solved-update-two-rows-with-two-where-statements/#findComment-547835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.