开发者

My project runs fine on local machine, but not on web server

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 ...
开发者_如何学C

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 ";

?>


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?).


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...


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜