942,782 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 123396
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 15th, 2006
0

PHP MySQL 5.0 stored procedure

Expand Post »
Any could give me a PHP script on how to call or execute mysql stored procedure.

Thank you.

Roland
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
rcasinillo_s is offline Offline
29 posts
since Jan 2006
Mar 21st, 2006
0

Re: PHP MySQL 5.0 stored procedure

Before you installed the php_mysqli.dll


<?php

/* Connect to a MySQL server */
$link = mysqli_connect(
'localhost', /* The host to connect to */
'root', /* The user to connect as */
'root', /* The password to use */
'db_name'); /* The default database to query */

if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error());
exit;
}


/* Send a query to the server */
if ($result = mysqli_query($link, "call se_proc('crm')")) {


/* Fetch the results of the query */
while( $row = mysqli_fetch_array($result) ){

echo ($row[0]. "--------- SR. " . $row[1] . "<br>");

}

/* Destroy the result set and free the memory used for it */
mysqli_free_result($result);
}

/* Close the connection */
mysqli_close($link);
?>
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ameer is offline Offline
2 posts
since Mar 2006
May 4th, 2008
0

Re: PHP MySQL 5.0 stored procedure

Oh it was simple, just execute "call proc_name"

http://fabinm.com/content/view/17/9/
Reputation Points: 10
Solved Threads: 1
Newbie Poster
kladizkov is offline Offline
2 posts
since May 2008
Sep 10th, 2008
0

Re: PHP MySQL 5.0 stored procedure

There is an article on this site which shows how to access Mysql Stored procedures using PDO and PHP
http://tejuspratap.co.cc/2008/08/29/...-using-php-50/
Last edited by thinktejas; Sep 10th, 2008 at 4:39 am.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
thinktejas is offline Offline
3 posts
since Sep 2008
Jan 27th, 2009
0

Re: PHP MySQL 5.0 stored procedure

Here's a quick tutorial on executing mysql stored procedures in php using mysql, mysqli, and pdo for the people using the different database extension:

http://www.joeyrivera.com/2009/using...ysqlmysqlipdo/
Reputation Points: 10
Solved Threads: 5
Light Poster
mazeroth is offline Offline
27 posts
since Jan 2009
Jul 13th, 2009
0

Re: PHP MySQL 5.0 stored procedure

Click to Expand / Collapse  Quote originally posted by thinktejas ...
There is an article on this site which shows how to access Mysql Stored procedures using PDO and PHP
http://tejuspratap.co.cc/2008/08/29/...-using-php-50/
The article has been moved to http://www.tejuspratap.com/main/node/18
Reputation Points: 10
Solved Threads: 1
Newbie Poster
thinktejas is offline Offline
3 posts
since Sep 2008
Jul 16th, 2009
0

Re: PHP MySQL 5.0 stored procedure

Click to Expand / Collapse  Quote originally posted by thinktejas ...
The article has been moved to http://www.tejuspratap.com/main/node/18
I am sorry I gave the wrong url before.

The article has been moved to http://www.tejuspratap.com/main/cont...s-using-php-50
Last edited by thinktejas; Jul 16th, 2009 at 4:26 am. Reason: I gave the wrong url before.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
thinktejas is offline Offline
3 posts
since Sep 2008
Nov 16th, 2009
0
Re: PHP MySQL 5.0 stored procedure
mysql Syntax (Toggle Plain Text)
  1. DROP PROCEDURE IF EXISTS `UsersR_DELETE_byPK`
  2. GO
  3.  
  4. CREATE PROCEDURE UsersR_DELETE_byPK
  5. (
  6. IN UsersID INT(11)
  7. )
  8. BEGIN
  9.  
  10. DELETE FROM UsersR
  11.  
  12. WHERE UsersID=UsersID;
  13.  
  14.  
  15. END
it is my stored proceder how to call php code perfom delete operation
Last edited by nav33n; Nov 16th, 2009 at 6:25 am. Reason: Please use [code] tags to wrap your code.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kbramprasath is offline Offline
2 posts
since Nov 2009
Dec 16th, 2009
0
Re: PHP MySQL 5.0 stored procedure
Any could give me a PHP script on how to call or execute mysql stored procedure.

Thank you.

Roland
I'll give you a very simple connection.. and how to call a procedure very simply. here it is -
------->
PHP Syntax (Toggle Plain Text)
  1. //first create a connection to your database...
  2. function connection(){
  3. $mysqli = new mysqli('$hostname','$dbusername', '$dbpassword', '$dbname');
  4. if (mysqli_connect_errno()) {
  5. printf("Connect failed: %s\n", mysqli_connect_error());
  6. exit();
  7. }
  8.  
  9. return $mysqli;
  10.  
  11. }
  12. //second create the function to call the stored procedure
  13. function query($query){
  14. //call the connection function
  15. if($result = connection()->query($query)){
  16. while($row = $result->fetch_assoc()){
  17. $data[] = $row;
  18. }
  19. return $data;
  20. }else {
  21. print('error on:'.$query.mysqli_error($this));
  22. }
  23. }
  24. //then call the function to execute stored procedure
  25. query("call store_proc('$param1')");
done! it's that simple... thanks
Last edited by Ezzaral; Feb 24th, 2010 at 12:26 pm. Reason: Added code tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
topspindex is offline Offline
1 posts
since Dec 2009
Feb 24th, 2010
0
Re: PHP MySQL 5.0 stored procedure
THat was an excellent reply.
Reputation Points: 9
Solved Threads: 14
Junior Poster
vsmash is offline Offline
100 posts
since Feb 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC