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...";

Recommended Answers

All 3 Replies

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'";
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.