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. Quote Link to comment 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. Quote Link to comment 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()); Quote Link to comment 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? Quote Link to comment 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 &&. Quote Link to comment 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.