MySQL UPDATE (2 lines of code...what's wrong)

[php]mysql_query(“UPDATE listings SET list_image = ‘.$list_image.’
WHERE list_id = ‘.$list_id.’”);[/php]
note:
listings is a table name

list_image is a column name

$list_image is a string that is the file path, name and extension (I know the string was made correctly because I used it to rename some files)

list_id is an auto-incrementing column in the table

$list_id is a number that I know to have successfully retrieved using mysql_insert_id()

It actually isn’t even registering an error, and I have it programmed to do so. It must be entering a NULL value…

HI there,

Get rid of the periods in your query syntax. The following should work for you:

[php]mysql_query(“UPDATE listings SET list_image = ‘$list_image’ WHERE list_id = ‘$list_id’”);[/php]

When you use double-quotes, when PHP parses what’s in between, any variable you have will be replaced with its value. Hope this helps.

Thank you so much OpzMaster. Doing anything in SQL from PHP has been such a hassle for me. All the places I find online have different suggestions, like putting parentheses around whatever is in the SET, and none of it seems to work…

Your help is greatly appreciated. I will keep that rule of thumb in mind as I go forward.

Sponsor our Newsletter | Privacy Policy | Terms of Service