justAnoob Posted May 15, 2009 Share Posted May 15, 2009 Sorry,, I have lots of questions..... I get a syntax error,, why?,,, everthing looks right. <?php mysql_query("INSERT INTO abcxyz(imgpath2)VALUES('$imgpath')WHERE id = '$idnumber'") or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/ Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 What's the syntax error message? Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834540 Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Author Share Posted May 15, 2009 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 id = '2'' at line 1 Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834541 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 OH, should have caught that. INSERT has no WHERE clause. http://dev.mysql.com/doc/refman/5.1/en/insert.html Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834545 Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Author Share Posted May 15, 2009 So then I can't insert something into a row with a specific id?(the id changes depending what picture they are viewing.) Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834552 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 Wait, so ID is not a PK? Um, in that case, just use INSERT with 2 value fields. Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834555 Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Author Share Posted May 15, 2009 Could I just use UPDATE instead of INSERT? I'll be back in a bit. I want to try a few things. Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834557 Share on other sites More sharing options...
justAnoob Posted May 15, 2009 Author Share Posted May 15, 2009 UPDATE works out good... Any downside to using it??? Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834559 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 UPDATE works out good... Any downside to using it??? Well everything has a down side. Just make sure you update just the info you want. Link to comment https://forums.phpfreaks.com/topic/158220-mysql-syntax-error-why/#findComment-834721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.