Skip to content
Advertisement

PHP Prepared MySQL UPDATE Statement with Variable inside of a string

I am trying to include a variable inside of a string in an update query but seem to be having trouble. I am just now updating all of my old websites to use prepared statements so I am not that familiar with them yet. What do I need to do to get the string and variable connected in the query.

I have tried without the single quotes, with the single quotes before the :file_name. But all I seem to get is errors. Any help would be greatly appreciated!

Advertisement

Answer

You want concat(), and query parameters rather than string concatenation:

Actually, CONCAT_WS() comes handy here:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement