jmr3460 Posted September 24, 2009 Share Posted September 24, 2009 What is wrong with this query. I keep 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 event_title = 'Leap Into Recovery' ORDER BY id LIMIT 1' at line 1" This is my query: $sql2 = "INSERT INTO calendar (first_day) VALUE (1) WHERE event_title = '$event' ORDER BY id LIMIT 1"; Can anyone tell me why this does not work? This column (first_day) is a bool, I have another query that uses this column to fetch an array that is echoed in a while satement. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/175307-solved-insert-query-not-working/ Share on other sites More sharing options...
corbin Posted September 24, 2009 Share Posted September 24, 2009 Errrr.... You cannot have a WHERE clause, an ORDER BY or a LIMIT clause in an insert query.... Looks like perhaps you're looking for an update query? (Can't have an ORDER BY clause in an UPDATE query.) Link to comment https://forums.phpfreaks.com/topic/175307-solved-insert-query-not-working/#findComment-923911 Share on other sites More sharing options...
jmr3460 Posted September 24, 2009 Author Share Posted September 24, 2009 OK I have a calendar and before this query I inserted three rows with the same information in it except for the date. I also have a while statement in another script that looks for the 1 in my first_day column and I just want to update the first row only so my other script does not show all three rows. Will this work: UPDATE table WHERE event_title = '$event' LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/175307-solved-insert-query-not-working/#findComment-923914 Share on other sites More sharing options...
jmr3460 Posted September 24, 2009 Author Share Posted September 24, 2009 Thanks for the help I got it. $sql2 = "UPDATE calendar SET first_day = 1 WHERE event_title = '$event' LIMIT 1"; Link to comment https://forums.phpfreaks.com/topic/175307-solved-insert-query-not-working/#findComment-923920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.