Sorry to triple post.
I think I've found out when the problem occurs, but still don't know how to sort it.
It seems that the problem is triggered when:
user_pref1 and user_pref2 are changed to the same value at the same time
(Changing one, then "saving profile", then changing the other and saving again doesn't seem to do it, they must be done at the same time)
AND
The value that both fields use contains a space
AND
A user attempts to change ONE value from the two same values
To escape the error you need to change BOTH values at the same time.
So I'm guessing this must be something to do with the space? Which doesn't help me solve it but could be useful to anyone who may be able to.
Any help would be massively appreciated.
Here is the query which causes the error, which seems fine to me (and I'm guessing is or it wouldn't work most of the time)
$userid = $_SESSION['user_id'];
$sql = "UPDATE
users
SET
user_firstname = '" . mysql_real_escape_string($_POST['user_firstname']) . "',
user_lastname = '" . mysql_real_escape_string($_POST['user_lastname']) . "',
user_email = '" . mysql_real_escape_string($_POST['user_email']) . "',
user_location = '" . mysql_real_escape_string($_POST['user_location']) . "',
user_phone = '" . mysql_real_escape_string($_POST['user_phone']) . "',
user_pref1 = '" . mysql_real_escape_string($_POST['user_pref1']) . "',
user_pref2 = '" . mysql_real_escape_string($_POST['user_pref2']) . "',
user_profile = '" . mysql_real_escape_string($_POST['user_profile']) . "'
WHERE
user_id = $userid";
$result = mysql_query($sql) or die(mysql_error(). include 'footer.php');