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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
steppinthrax
Forum Newbie
Posts: 4
Joined: Thu Mar 11, 2010 3:02 pm

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

Post 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.....
steppinthrax
Forum Newbie
Posts: 4
Joined: Thu Mar 11, 2010 3:02 pm

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

Post by steppinthrax »

Never Mind i got it working

I changed everything to mysqli and it started working....
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

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

Post 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
Post Reply