Page 1 of 1

FOR THE LIFE OF ME I CAN'T CALL A STORED PROCEDURE FROM PHP

Posted: Tue Apr 20, 2010 11:07 am
by steppinthrax
This is my code:

Code: Select all

<?php
/*Includes for the hours*/
$link = mysql_connect("localhost", "AppUser_HAE", "1234");
if (!$link) 
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("HAE", $link);

$result = mysql_query("call hae.disp_cch");

while($row = mysql_fetch_array($result))
  {
  $cch_mo = $row['cch_mo'];
  $cch_tu = $row['cch_tu'];
  $cch_we = $row['cch_we'];
  $cch_th = $row['cch_th'];
  $cch_fr = $row['cch_fr'];
  $cch_sa = $row['cch_sa'];
  $cch_su = $row['cch_su'];
  $cch_c1 = $row['cch_c1'];
  $cch_c2 = $row['cch_c2'];
  $cch_c3 = $row['cch_c3'];
  $cch_c4 = $row['cch_c4'];
  $cch_c5 = $row['cch_c5'];
 }


mysql_close($link);

?> 
 
This is very simple. I have an account named AppUser_HAE. I have a stored procedure named hae.disp_cch. disp_cch has all records I'm trying to fetch. I tried this with a simply select * from table and it works perfecly. However, if I try to use the stored procedure I get an error at the mysql_fetch_array(), because no data is coming back from the server.

I've given AppUser_HAE permissions for execute grant to all the stored procedures. I've also even logged into the mysql server with the AppUser_HAE and executed the procedure myself and it works.

What's going on here.....

Re: FOR THE LIFE OF ME I CAN'T CALL A STORED PROCEDURE FROM

Posted: Tue Apr 20, 2010 11:37 am
by steppinthrax
Never Mind i got it working

I changed everything to mysqli and it started working....

Re: FOR THE LIFE OF ME I CAN'T CALL A STORED PROCEDURE FROM

Posted: Fri Apr 30, 2010 7:50 pm
by mecha_godzilla
Hmm...how is it that I must have looked at hundreds of PHP/MySQL tutorials and never once seen any mention of mysqli() even though the PHP developers specifically recommend using it. More details here for anyone that's interested:

http://uk.php.net/manual/en/mysqli.overview.php

Does anyone know when the mysqli extension was added to PHP 5?

Mecha Godzilla