| | |
PHP MySQL 5.0 stored procedure
Thread Solved |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 1
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);
?>
<?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);
?>
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 1
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/
http://tejuspratap.co.cc/2008/08/29/...-using-php-50/
Last edited by thinktejas; Sep 10th, 2008 at 4:39 am.
•
•
Join Date: Jan 2009
Posts: 16
Reputation:
Solved Threads: 3
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/
http://www.joeyrivera.com/2009/using...ysqlmysqlipdo/
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 1
•
•
•
•
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/
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 1
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
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.
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#8 Nov 16th, 2009
mysql Syntax (Toggle Plain Text)
DROP PROCEDURE IF EXISTS `UsersR_DELETE_byPK` GO CREATE PROCEDURE UsersR_DELETE_byPK ( IN UsersID INT(11) ) BEGIN DELETE FROM UsersR WHERE UsersID=UsersID; END
Last edited by nav33n; Nov 16th, 2009 at 6:25 am. Reason: Please use [code] tags to wrap your code.
•
•
Join Date: Dec 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#9 Dec 16th, 2009
•
•
•
•
Any could give me a PHP script on how to call or execute mysql stored procedure.
Thank you.
Roland
------->
//first create a connection to your database...
function connection(){
$mysqli = new mysqli('$hostname','$dbusername', '$dbpassword', '$dbname');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
return $mysqli;
}
//second create the function to call the stored procedure
function query($query){
//call the connection function
if($result = connection()->query($query)){
while($row = $result->fetch_assoc()){
$data[] = $row;
}
return $data;
}else {
print('error on:'.$query.mysqli_error($this));
}
}
//then call the function to execute stored procedure
query("call store_proc('$param1')");
done! it's that simple... thanks
![]() |
Similar Threads
- PHP and MySQL Web Development (PHP)
- free php/mysql programming (Web Development Job Offers)
- master database with php mysql (Legacy and Other Languages)
- Stored procedure call with ADO (C)
- Integrating Apache with PHP and MySQL (Linux Servers and Apache)
- Using PHP, MySQL and Apache Server (PHP)
Other Threads in the PHP Forum
- Previous Thread: Mulptiple textbox for search
- Next Thread: User authentication problem
Views: 61814 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess ajax apache api archive array arrays beginner binary broken cakephp check checkbox class classes cms code combobox cron curl database date development directory display download dynamic echo email error file files folder form forms function functions google header hosting htaccess html image include insert ip java javascript joomla jquery limit link list login loop mail mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio recursion regex remote results rewrite script search select server sessions sms source space speed sql storage syntax table tutorial unicode update updates upload url user validation validator variable video web xml





