elmas156 Posted August 16, 2011 Share Posted August 16, 2011 Hey everyone, I'm getting this error message: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE email = 'ataylor'' at line 1" On this code: " mysql_query("INSERT INTO `staff` (email,pword) VALUES ('$email','$pword') WHERE email = 'ataylor'") or die (mysql_error()); I'm having a hard time figuring out what is wrong. Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/ Share on other sites More sharing options...
elmas156 Posted August 16, 2011 Author Share Posted August 16, 2011 Sorry, just realized I posted this in PHP Coding Help and not MySQL help... Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258287 Share on other sites More sharing options...
Alex Posted August 16, 2011 Share Posted August 16, 2011 INSERT queries shouldn't have WHERE statements. What are you trying to do? If you're trying to update a row you should be using an UPDATE query. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258288 Share on other sites More sharing options...
elmas156 Posted August 16, 2011 Author Share Posted August 16, 2011 I just realized that. This is what too much work will do to you... make you overlook silly mistakes. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258291 Share on other sites More sharing options...
elmas156 Posted August 16, 2011 Author Share Posted August 16, 2011 OK, different query, different problems... When I use this: mysql_query("UPDATE `staff` SET `email` = '$email',`pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Only the pword field is updated... This: mysql_query("UPDATE `staff` SET `email` = '$email' WHERE staffid = '$staffid'") or die (mysql_error()); mysql_query("UPDATE `staff` SET `pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Only updates the email field... And this: mysql_query("UPDATE `staff` SET `pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Does absolutely nothing... I'm getting no errors at all. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258304 Share on other sites More sharing options...
fenway Posted August 17, 2011 Share Posted August 17, 2011 Echo the queries. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258383 Share on other sites More sharing options...
elmas156 Posted August 17, 2011 Author Share Posted August 17, 2011 what do you mean "echo the queries?" Sorry, I'm still learning. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258392 Share on other sites More sharing options...
fenway Posted August 17, 2011 Share Posted August 17, 2011 I mean dump the strings that those queries represent. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258395 Share on other sites More sharing options...
elmas156 Posted August 17, 2011 Author Share Posted August 17, 2011 Well, I still have no idea what the problem was, but I re-wrote the code for the entire page, and now everything is working fine. I think it had something to do with my server. Oh well, it works now. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/244956-need-another-set-of-eyes/#findComment-1258397 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.