views:

101

answers:

2

Hi

I tried to upload my project on my machine and the error that I get from mysql is:

execute command denied to user 'tisegoco_goitse'@'localhost' for routine 'tisegoco_tisego.offices

I granted this user all privileges on the db.

Now I am trying to access this procedure:

delimiter //
create procedure sample()
begin
      select * from tblusers;
end
delimiter ;

and the php code is as follows:

require ("db.php");
$db = dbConnect();

$result = $db->query("CALL sample()");
echo $db->error;
while(list($id, $city, $address) = $result->fetch_array())
echo "($id) $city: $address <br />";

Please help thank you.

A: 

You're probably on a shared-server.

Cpanel/PHPMyAdmin does not allows user to give execute permission on cPanel based shared-servers. The issue can only be fixed by your webhost company having root access. Ask them to grant required permissions.

Even if you grant all permissions yourself, you are not going to get the execute permissions.

shamittomar
A: 

Forget the stored procedures for now and try to do a simple query to see like so.

Take it in small steps.

<?php

    require ("db.php");

    $db = dbConnect();

    echo 'Doing query...';

    $result = $db->query("SELECT * FROM offices");

    if (!(is_object($result)))
      {
      echo 'No result returned from query';
      //echo $db->error;
      }
    else 
      {

      while(list($id, $city, $address) = $result->fetch_array())
        {
        echo "($id) $city: $address \n";
        }
      }


    ?>
JW
This works perfectly, but not my stored procedure
mneva
'works perfectly' - I'd stop there. You have to question whether you need to use stored procedures at all. If they are essential (which is unlikely considering MySQL survived up to version 5 without them), then you will need to ensure that the db user has 'execute' privileges on the 'offices' table to make your app function. How easy that is to do depends on your hosting set-up/ your ability to switch hosts. Read this first though: http://xprogramming.com/Practices/PracSimplest.html
JW