A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearMySQL stored procedure: can't run from PHP code - page 1
User InfoPosts
MySQL stored procedure: can't run from PHP code#1
I have the below stored procedure to check the user name availability

DELIMITER $$;

DROP PROCEDURE IF EXISTS tv_check_email$$

CREATE PROCEDURE tv_check_email (IN username varchar(50))
BEGIN
select USER_ID from tv_user_master where EMAIL=username;
END$$

DELIMITER ;$$


When I run this from my MySQL front end tool, it is works just fine:

call tv_check_email((shyju@techies.com()


But when trying to execute from the PHP page, I get an error like

"PROCEDURE mydatabase.tv_check_email can(t return a result set in the given context"


I am sure that my PHP version is 5.2.6.

posted date: 2009-04-08 21:18:00


Re: MySQL stored procedure: can't run from PHP code#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-08 21:18:01


Re: MySQL stored procedure: can't run from PHP code#3
You need to bind your result into an OUT parameter. See the mysql docs on stored proceduresmysql> delimiter //mysql> CREATE PROCEDURE simpleproc (OUT param1 INT) -> BEGIN -> SELECT COUNT(*) INTO param1 FROM t; -> END; -> //Query OK, 0 rows affected (0.00 sec)mysql> delimiter ;mysql> CALL simpleproc(@a);Query OK, 0 rows affected (0.00 sec)mysql> SELECT @a;+------+| @a |+------+| 3 |+------+

posted date: 2009-04-08 21:23:00


Re: MySQL stored procedure: can't run from PHP code#4
It looks like if you use the mysqli PHP library you can actually retrieve your result set without having to use an OUT variable and another query to retrieve your value. This article covers the details:http://amountaintop.com/php-5-and-mysql-5-stored-procedures-error-and-solution-qcodo

posted date: 2009-04-08 21:33:00


Re: MySQL stored procedure: can't run from PHP code#5
thanks cody , it worked

posted date: 2009-04-08 22:21:00


Re: MySQL stored procedure: can't run from PHP code#6
Cody is not 100% right. You can bind your resulting return columns and return select data from within a stored procedure.$mysqli = new mysqli("localhost", "my_user", "my_password", "world");$stmt = $mysqli->prepare("call tv_check_email(?)");$stmt->bind_param((s(, "shyju@techies.com");$stmt->execute();$stmt->bind_result($userid);while ($stmt->fetch()) { printf("User ID: %d\n", $userid);}$stmt->close();$mysqli->close();

posted date: 2009-04-09 07:36:00


Re: MySQL stored procedure: can't run from PHP code#7
Ah yes, much better. From my understanding, the std. mysql extension doesnt support accessing result sets w/o OUT, but the mysqli does (as your code indicates)? Good to know.

posted date: 2009-04-09 21:51:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.