Upgraded to php 4.2.1, broke a script

der.hans plug-discuss@lists.plug.phoenix.az.us
Wed, 15 May 2002 18:27:39 -0700 (MST)


Am 15. May, 2002 schwätzte Kevin Brown so:

> Tried posting this to the php list last week, but it went down and hasn't come
> back since.
>
> Just upgraded the php on my poor little DEC Alpha multia that is running on the
> internal network here and it broke one of my php pages that pulls an image from
> a db and displays it (yes I know, poor performance).  The script was working as
> is with 4.1.2.
>
> show_image.php:
>
> <?
> include("movie_conf.php");
> dbConnect();
>
> $get_image = "select binary_junk, filetype from images where img_id = '$imgid'";
> $get_image_result = mysql_query($get_image);
>
> $binary_junk = mysql_result($get_image_result,0,"binary_junk");
> $filetype = mysql_result($get_image_result,0,"filetype");
>
> header("Content-type: $filetype");
> echo "$binary_junk";
> ?>
>
> Sample call: http://10.0.0.120/movies/show_image.php?imgid=92
>
> output from it is:
>
> Warning: Unable to jump to row 0 on MySQL result index 2 in
> /home/httpd/html/movies/show_image.php on line 8

First, make sure you got a result, then make sure there's data in it.

$get_image_result = mysql_query($get_image);
if( $get_image_result ) {
	$num_rows = mysql_num_rows( $get_image_result );
	if ( $num_rows > 0 ) {
		// got results
		// do stuff
	} else {
		// didn't get results
		// catch error
	}
}

Have you tried the query from msql ( I think that's the name, it's psql for
the postgreSQL version )?

ciao,

der.hans
-- 
#  https://www.LuftHans.com/
#  kill telnet, long live ssh - der.hans