Solved

Calling a MySQL Stored Procedure

Posted on 2006-11-22
2
218 Views
Last Modified: 2013-12-12
Hi guys,

What's the syntax for calling a MySQL Stored Procedure, and looping through the results? (It's a bunch of queries and gives out results)

Cheers!
0
Comment
Question by:Cyber-Drugs
2 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17999812
Hi,

You should be able to treat the output as a normal query - noting that you have to use mysqli

$query = "Call dbName.StoredProc($param1, $param2)";

if ($result = mysqli_query($link, $query)) {

   /* fetch associative array */
   while ($row = mysqli_fetch_assoc($result)) {
       printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
   }

   /* free result set */
   mysqli_free_result($result);
}


(above is manipulation of example from http://uk2.php.net/manual/en/function.mysqli-fetch-assoc.php)
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 17999833
Cheers Raynard7! :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now