ok so i am running into this problem that i cant seem to fix. trying to make a dynamic query. i am grabbing variables from post data and trying to put them in the query but everytime i try to run the query it doesnt work.

$id = $_POST["id"];
$imagenum = $_POST["imagenum"];
$filename //Works fine creates a random name then uploads the image with that name

		$query2 = "UPDATE properties SET $imagenum = '$filename' WHERE id='$id'";
		$result2 = mysql_query($query2);

it seems even if i was to use '$imagenum' instead it still doesnt work.

but when i use the real field name imageone it works.

can you help me with trying to make this dynamic. trying for less code.

thanks in advance

6 Years
Discussion Span
Last Post by itisnot_me

I have tried it it is working,
Below queries are working fine for me
$query2 = "UPDATE properties SET $imagenum = '$filename' WHERE id='$id'";
$query2 = "UPDATE properties SET `$imagenum` = '$filename' WHERE id='$id'";

You may be try `$imagenum` (quoted in tilted) rather than '$imagenum' or \"$imagenum\".

'$imagenum' or \"$imagenum\" are also not working for me.
Try to understand my english.


the ` works. thanks.

now a stupid question. how do i make those instead of '


oh duh. its the button that i never look or pay attention to. the ~ button

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.