You are here: Re: Stored procedures, MySQL, and PHP « PHP Programming Language « IT news, forums, messages
Re: Stored procedures, MySQL, and PHP

Posted by Jerry Stuckle on 04/02/07 17:10

eholz1 wrote:
> Hello PHP group,
>
> Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0
> running on Linux (Redhat Fedora Core 6).
>
> All that works fine. I would like to be able to "call" a stored
> procedure from a PHP program, and
> run a stored procedure. I have yet to figure out the proper way to do
> this. My stored procedures work fine from the mysql command line
> using syntax: "call sp_min_record (101);"
>
> But when I try to do the same thing within my PHP page - no luck I get
> an error.
>
> Here is my stored procedure code:
>
> DELIMITER $$
>
> DROP PROCEDURE IF EXISTS `portfolios`.`sp_min_record` $$
>
> CREATE DEFINER=`ewh`@`localhost` PROCEDURE
> `portfolios`.`sp_min_record`
> (IN folio INT)
> BEGIN
> SELECT MIN(id) INTO minr FROM images3 WHERE p = folio;
> END$$
>
> DELIMITER ;
>
> and here is how I am trying to call it from php:
>
> $dbconnect = db_connect('portfolios') or trigger_error("Error
> Connecting to Database: "
> . mysql_error(), E_USER_ERROR);
>
> $help = @mysql_query("call sp_min_record ($folio)");
> $rowx = @mysql_fetch_assoc($help);
>
> $minrec = $rowx[0];
>
> but I get no value returned. How am I supposed to do this
> (correctly :))?
> Thanks,
> eholz1
>

First of all, get rid of the '@' characters. Then check the results of
mysql_query to see if you got an error. If so, print the error and see
what's actually happening.

Pet Peeve: Why do people disable error reporting with '@', don't check
the results of their calls, then come asking why it isn't working?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация