Insert PHP variable in to MySQL database?
Hello all,
I have an integer stored in a variable named $userid and am trying to insert it in to a MySQL database.
I have been trying to use the following query:
$query = "INSERT INTO rota (userid, person) VALUES ('$userid','".db_escape($_POST['person'])."')";
Now, the query executes with no problem and the person value is correctly stored in the database. However, the userid variable inserts as '0' even though the value is actually '65'.
I have been trying everything I can for hours and no matter what I do the query always inserts '0' instead of the actual value of $userid which is '65'.
Any help at all would be HUGELY appreciated!
Thank you in advance.
Re: php variable insert problem
Quote:
Originally Posted by
Mindzai
What is the output of the following, placed directly before the mysql_query call:
PHP Code:
var_dump($userid);
sorry, I meant to say var_dump returns NULL Any ideas?
Thanks alot!
Sam