Jump to content

conditional insert where clause issue


davidcriniti

Recommended Posts

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());

Link to comment
https://forums.phpfreaks.com/topic/255967-conditional-insert-where-clause-issue/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.