davidcriniti Posted January 29, 2012 Share Posted January 29, 2012 Hi, I've been playing around with inserting the name of a file ($additional_upload_nameX) into the database only if it has been uploaded (it's not mandatory). When I submit the form, I'm told I have a problem with my WHERE clause. Any idea what I'm doing wrong here? $query2 = "INSERT INTO uploads (date, upload_name, topic, year, status, keywords, description )" . "VALUES (NOW(), '$additional_upload_nameX', '$topic', '$year', '$status', '$keywords' , '$description') WHERE $additional_upload_nameX != ''"; //if($query){echo 'data has been placed'} mysql_query($query2) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/255967-conditional-insert-where-clause-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2012 Share Posted January 29, 2012 INSERT queries don't have WHERE clauses. Your php code would need to determine when a file has not been uploaded and put a default value into the query statement for the upload_name column or use a query that doesn't have that column listed in it and let the database use the default value you have defined for that column. Quote Link to comment https://forums.phpfreaks.com/topic/255967-conditional-insert-where-clause-issue/#findComment-1312126 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.