top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to call stored mysql procedure in PHP?

0 votes
473 views
How to call stored mysql procedure in PHP?
posted Jul 16, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You can call a stored procedure using the following syntax:

$result = mysql_query('CALL procedure_name()');

Example Code :

<?php 

  //Connect to database
  $connection = mysqli_connect("hostname", "user", "password", "db", "port");

  //Run the store proc
  $result = mysqli_query($connection, 
     "CALL StoreProcName") or die("Query fail: " . mysqli_error());

  //Loop the result set
  while ($row = mysqli_fetch_array($result)){   
      echo $row[0] . " - " . + $row[1]; 
  }

?>
answer Aug 7, 2014 by Manish Tiwari
Similar Questions
+2 votes

I have a date field on an html form that users may leave blank. If they do leave it blank I want to write the date 01/01/1901 into the mysql table. How can I accomplish this and where in my .php script file should I put the code?

...