0

Hi,
I am a beginner in php mysql... I want to pass null values to integer from PHP file to mysql stored procedure.

eg:
$name = "John";
$age = $_POST; // Which is a null value..

and i called the procedure like CALL InsertStudent('$name',$age);

my procedure is not executing ... But it works fine if the $age has some values...

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by petr.pavel
0

Hi Anish, I don't quite understand your description. What do you mean by "pass null values to integer"?

PHP NULL values won't be passed to MySQL as NULL you have to explicitly type NULL.
Example:

if ($value === NULL)
  $sqlValue = "NULL";
else
  $sqlValue = "'".mysql_real_escape_string($value)."'";

mysql_query("INSERT INTO mytable (myattribute) VALUES ($sqlValue)");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.