I am struggling to update my MySQL database.
This is what I have written:
$mysql_link = mysql_connect('servername','username','password');
mysql_select_db('bambi4couk_599731_db3', $mysql_link);
$serializedTemplates = serialize($_SESSION['data']['user']['templates']);
mysql_query("UPDATE rmusers SET templates='$serializedTemplates' WHERE email='" . $_SESSION['data']['user']['details']['email'] . "'");
How can I fix this to make it work?
EDIT:
I am not getting an error but the function is not updating the database and it is returning false.
$_SESSION[‘data’][‘user’][‘details’][’email’] returns the email address used (which does appear in the database).
The serialized array is too long to paste here but there are no problems with it – it is a string anyway so I don’t see how it could be wrong.
EDIT2:
As it turned out my assumption was wrong, the serialized array had to be escaped first.
Add
Like this
Then tell us what the error message is, so we can help you
At a guess I would expect you have not escaped the values
see mysql_real_escape_string()
http://www.php.net/manual/en/function.mysql-real-escape-string.php