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...

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)");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.