At 10:09 AM +0200 10/15/99, Sébastien FERRANDEZ wrote:
>I am facing a warning problem for a program that a guy before me wrote :
>
>$suggestion="regy2";
>$ip=mysql($v, "select * from suggestions where page='$suggestion'");
>
>$ref[0]=mysql_result($ip,0,"ref1"); if($ref[0]!=""): $i=0;
>include("suggestions.php3"); endif;
>$ref[1]=mysql_result($ip,0,"ref2"); if($ref[1]!=""): $i=1;
>include("suggestions.php3"); endif;
>$ref[2]=mysql_result($ip,0,"ref3"); if($ref[2]!=""): $i=2;
>include("suggestions.php3"); endif;
>$ref[3]=mysql_result($ip,0,"ref4"); if($ref[3]!=""): $i=3;
>include("suggestions.php3"); endif;
>
>Message sent for each of these lines : Warning: Unable to jump to row 0
>on MySQL result index
>Is it a compatibility problem due to downwards incompatibility problems
>in PHP 3.0.
>
This is more of a PHP question, but...
How many rows are there in the result set? You can check by sticking a
echo mysql_num_rows($ip);
after the $ip=mysql(...); line. If the result is an empty set, I
could see that error message being generated.
Now, it's hard to tell definitively from this code snippet, but I
have a few suggestions.
(1) No error checking is apparent. I would do something like
if ($ip) {
$ref[0]=mysql_result($ip,0,"ref1"); if($ref[0]!=""): $i=0;
include("suggestions.php3"); endif;
...
} else {
echo 'Database error: ', mysql_error();
...
}
(2) This code uses older forms of PHP mysql statements. See
http://www.php.net/manual/function.mysql-result.php3
for recommended - faster & more versatile - alternatives to
mysql_result(), and mysql() has been superceded by mysql_db_query().
On the other hand, you might be using an old version of PHP (current
version is 3.0.12).
-steve
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg University of California, Davis |
| sbedberg@stripped (530)754-9127 |
| Computer Consultant http://aesric.ucdavis.edu/ |
+---------------- said t e lawrence, picking up his fork ----------------+