top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to call stored mysql procedure in PHP?

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

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...