views:

68

answers:

5

My project is working fine on my local machine but not on the web server. I think it is the stored procedures, because the error that I am getting is:

Fatal error: Call to a member function fetch_array() on a non-object in ...

The collation of the database is "utf8_general_ci".

Just a simple example:

I have a stored procedure called offices:

CREATE PROCEDURE offices()

BEGIN

SELECT * FROM offices; 
END//

And the php code:

<?php 
require ("db.php");

$db = dbConnect();

$result = $db->query("CALL offices()");

while(list($id, $city, $address) = $result->fetch_array())

echo "($id) $city: $address ";

?>
+1  A: 

What happens on the database server, when you CALL offices() manually? Any errors? If I had to guess, it looks like the offices() function is not defined on the server, or fails when invoked (table offices doesn't exist?).

Piskvor
A: 

To me it looks like the $result is not a object or not initialized. Can you show us the code in your db library. Specifically the query function...

Johan
A: 

Make sure your db user which was used to install the schema has privileges to create stored procedures. If you are unsure if they are on the server, you can do

SELECT * FROM `information_schema`.`ROUTINES`;

..to see which procedures have been succesfully created.

Keep in mind the majority of shared hosting services do not support triggers, procedures etc.

danp
A: 

you are probably running a different version of your database at the remote server. so the query method is failing and is not returning what should return.

hugo_leonardo
A: 

Looks like your auth does not have allowed to use DB procedures at the server

palmic