Basic PHP/mySql question

Sm1th

n00b
Joined
Feb 20, 2011
Messages
9
Ok,

Code:
	public function execSql(){

		$result = mysql_query('select * from users');
		$data = array();
		while($row = mysql_fetch_assoc($result))
		{
			$data[] = $row;
		}
		//print_r($data);
		mysql_free_result ($result);
		
		return $data;
               
	}

Why would this function return rows as normal, but changing the

Code:
$result = mysql_query('select * from users');

to...
Code:
$result = mysql_query('call searchUsers()');

not return anything??

Sql:

Code:
DELIMITER $$

USE `instantmessenger`$$
DROP PROCEDURE IF EXISTS `searchUsers`$$


CREATE
    /*[DEFINER = { user | CURRENT_USER }]*/
    PROCEDURE `instantmessenger`.`searchUsers`()

    BEGIN
	SELECT * FROM users;
    END$$
 
What does "mysql_error" return when run immediately after the problem line of code?
 
MySQL error 1312: PROCEDURE instantmessenger.searchUsers can't return a result set in the given context
When executing:
call searchUsers()

Something wrong with the proc?
 
Something wrong with the proc?
Just looking at the error statement, it may be that the DB connection you are running from in your PHP code doesn't have permissions to that proc.

Alternatively, you could try the "mysqli_" objects.
 
Back
Top