I have a query which runs fine if I manually declare $add to be a value (30 for example) by when I try to set it to the user_id session the query fails.
// $add = 30;
// The line above works
$add = mysql_real_escape_string($_SESSION['user_id']);
$query = "UPDATE mytable SET act=0, add=$add WHERE id=$selected_user";
Any ideas where I’m going wrong.
When using sessions you always need to specify this before any
$_SESSIONusage like this:By the other hand, I got the same problem as you before and what you need to do is to
put the
$_SESSION['user_id']in a variable, then you will be able to pass it to themysql_real_escape_stringwithout problems.Hope this helps.