| | |
Out parameter does not work with mysql.? Help me
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 119
Reputation:
Solved Threads: 2
This is my Stored Procedure
DELIMITER $$
This is my Php Code to call StoreProcedure
Can anyone tell where i m wrong..
is it true that Out parameter doesnt work with mysql..???
Help me out
DELIMITER $$
mysql Syntax (Toggle Plain Text)
DROP PROCEDURE IF EXISTS `CALL`.`sp_login`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_login`(userid VARCHAR(50),pass VARCHAR(50),out chk INT(11),out user_alias VARCHAR(50),out user_tariff VARCHAR(50),out c_credit DECIMAL(15,5),out r_reseller VARCHAR(10),out r_level VARCHAR(10),out c_tariff CHAR(2)) BEGIN SELECT id INTO chk FROM cc_reseller WHERE useralias =userid AND uipass=pass AND level!=0 AND activated!='0'; if(chk!="") THEN SELECT id,useralias,tariff,credit,reseller,level,create_tariff INTO chk,user_alias,user_tariff,c_credit,r_reseller,r_level,c_tariff FROM cc_reseller WHERE useralias =userid AND uipass=pass AND activated!='0' AND level!=0; END if; END$$ DELIMITER ;
This is my Php Code to call StoreProcedure
php Syntax (Toggle Plain Text)
<?php ob_start(); include_once('config.php'); $username = $_POST['username']; $password = $_POST['password']; if (isset($_POST['username']) && $_POST['username']!='') { $username=$_POST['username']; $password=$_POST['password']; $query="call sp_login('$username','$password',@chk,@user_alias,@user_tariff,@c_credit,@r_reseller,@r_level,@c_tariff)"; $result=mysql_query($query) or die('Query error'.''.mysql_error()); $count=mysql_fetch_row($result); $chk = $count[0]; if($chk !="") { $n_name = $count[1]; $n_tariff = $count[2]; $n_username = $count[3]; $n_creator = $count[4]; $n_credit = $count[5]; $_SESSION['username'] = $n_username; $_SESSION['user_id'] = $chk; $_SESSION['tariff'] = $n_tariff; $_SESSION['reseller'] = $n_creator; $_SESSION['ncredit'] = $n_credit; header('Location:welcomes.php'); } else { header("location:index.php?q=-2"); } } else { if(!isset($_SESSION['username']) || $_SESSION['username']=='') { header("location:index.php?q=-1"); } } ?>
Can anyone tell where i m wrong..
is it true that Out parameter doesnt work with mysql..???
Help me out
Last edited by sam023; Oct 29th, 2009 at 3:26 am.
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#2 Oct 29th, 2009
No its not true, what error you get..?
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Jun 2009
Posts: 119
Reputation:
Solved Threads: 2
0
#3 Oct 29th, 2009
PHP Syntax (Toggle Plain Text)
Query errorPROCEDURE call.sp_login can't return a result set in the given context
Well i google little bit..!!
i got this article
http://www.artfulsoftware.com/infotree/tip.php?id=130
in it is said that Mysql Api cannot fetch out parameter..!!!
may be thats why people use mysqli..??
What do u say..?
•
•
Join Date: Jun 2009
Posts: 119
Reputation:
Solved Threads: 2
0
#5 Oct 29th, 2009
PHP Syntax (Toggle Plain Text)
$con = mysql_connect('localhost','root','',false,65536);
last two parameters makes the difference..!!
now my procedure is running..!!!
Thanks for the link
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#6 Oct 29th, 2009
great, have a nice time
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#8 Oct 30th, 2009
•
•
•
•
still i dont understand the use and meaning of last two parameters..??
what is the use of it..!! earlier i never use it..?
Can u tell me that
the the but one parameter is called new_link, if its set to true, each time you call mysql_connect() new connection is created and that MYSQL link identifier is returned back.Otherwise no new link will be established, but instead, the link identifier of the already opened link will be returned.
and the last parameter called client_flags is an integer actually, has values like 'MYSQL_CLIENT_IGNORE_SPACE ', 'MYSQL_CLIENT_COMPRESS' and 'MYSQL_CLIENT_INTERACTIVE' etc.
Don't worry much about this last one, if you don't need it at the moment.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Jun 2009
Posts: 119
Reputation:
Solved Threads: 2
0
#9 Oct 30th, 2009
•
•
•
•
sure, this last two parameters are optional,
the the but one parameter is called new_link, if its set to true, each time you call mysql_connect() new connection is created and that MYSQL link identifier is returned back.Otherwise no new link will be established, but instead, the link identifier of the already opened link will be returned.
and the last parameter called client_flags is an integer actually, has values like 'MYSQL_CLIENT_IGNORE_SPACE ', 'MYSQL_CLIENT_COMPRESS' and 'MYSQL_CLIENT_INTERACTIVE' etc.
Don't worry much about this last one, if you don't need it at the moment.
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#10 Oct 30th, 2009
yes, they seems to be important for stored procedures to execute -
When you connect and expect to use a stored procedure,you must pass a special flag to MySQL via the connect command, otherwise you will not get the results returned, and it will result in this error:
PROCEDURE AlexGrim.GetStats_ForumCategories can't return a result set in the given context
To fix this, change you connection string, adding ",false,65536" as the last 2 fields:
$this->con = mysql_connect($this->h,$this->u,$this->p,false,65536);
This is what you did.Because the constant 65536 represents the "CLIENT_MULTI_STATEMENTS", which will enable the support for using multiple statement in the query.
Why to use this, must be obvious now for you, as stored procedures are likely to have multiple statements
When you connect and expect to use a stored procedure,you must pass a special flag to MySQL via the connect command, otherwise you will not get the results returned, and it will result in this error:
PROCEDURE AlexGrim.GetStats_ForumCategories can't return a result set in the given context
To fix this, change you connection string, adding ",false,65536" as the last 2 fields:
$this->con = mysql_connect($this->h,$this->u,$this->p,false,65536);
This is what you did.Because the constant 65536 represents the "CLIENT_MULTI_STATEMENTS", which will enable the support for using multiple statement in the query.
Why to use this, must be obvious now for you, as stored procedures are likely to have multiple statements
Last edited by network18; Oct 30th, 2009 at 5:23 am. Reason: light on using stored procedure in php
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- i want the best php class to work with mysql (PHP)
- does Command parameter work while using mysql as ODBC connecton (VB.NET)
- Query not work in MYSQL 4 only in 5.. (MySQL)
- can asp work with mySQL (ASP)
- configure PHP to work with Mysql (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Pleas help
- Next Thread: how do i delete a directory with php?
| Thread Tools | Search this Thread |
Tag cloud for mysql, parameter, procedure, sp, stored
"use" .net 1 @param amazon api archive array backup button buyouts c# c++ cache cakephp calendar calling check connect data database date design display doctype download dropdownlist ec2 eliminate email error events file flash form forms functions glassfish google html ibm if...loop image innerjoins innodb insert java javadoc javascript keyword keywords kickfire links linux load matching memory mergers migrate montywidenius msqli_multi_query multiple mysql mysqldb mysqlindex mysqlquery mysqlsearch netbeans opendatabasealliance operand oracle parameter parsing php phpmyadmin procedure programming query ram read recourse reference restore return search select server simpledb sorting sp speed sqlserver ssh statement stored sun thread update upload view






