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

Recommended Answers

All 4 Replies

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 '

I think you can type those.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.