Do anyone see what im doing wrong with the update query?
i get this mysql_error message;

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-xxx WHERE id = '616' AND userid = '15'' at line 1

$query = "SELECT * FROM ue-xxx WHERE id = '$imageid' AND userid = '$userid'";
	$result = mysql_query($query) or die(mysql_error());

	$row = mysql_fetch_array($result) or die(mysql_error());

$result6 = mysql_query("UPDATE `ue-xxx` SET `albumname` ='$newalbum' WHERE `albumname` ='$oldalbum' BY `id` ='$imageid'")or die(mysql_error()); 
	if($result6){echo "Done!";}else echo "Something went wrong...";

Edited by Sorcher: n/a

5 Years
Discussion Span
Last Post by karthik_ppts

BY is your issue, change it the WHERE (line 7 of posted code.

$result6 = mysql_query("UPDATE `ue-xxx` SET `albumname` ='$newalbum' WHERE `albumname` ='$oldalbum' WHERE `id` ='$imageid'")or die(mysql_error());

I have never used where twice, so I don't know if it woun't give an error. I do it like this:

$result6 = mysql_query("UPDATE `ue-xxx` SET `albumname` ='$newalbum' WHERE `albumname` ='$oldalbum' and `id` ='$imageid'")or die(mysql_error());

with 2 where it might work, just newer tried it :)


That error is not with update query. Its because of the select query.
try this

$query = "SELECT * FROM `ue-xxx` WHERE id = '$imageid' AND userid = '$userid'";

Edited by karthik_ppts: n/a

This topic has been dead for over six months. 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.