#26136 [Opn->Bgs]: mysql_fetch_row mysql_result interaction
| From: | iliaa@php.net | Date: | Wed, 05 Nov 2003 16:15:05 +0000 |
| Subject: | #26136 [Opn->Bgs]: mysql_fetch_row mysql_result interaction | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-50045@lists.php.net to get a copy of this message | ||
ID: 26136
Updated by: iliaa@php.net
Reported By: dario_primorac at net dot hr
-Status: Open
+Status: Bogus
Bug Type: Output Control
Operating System: Linux
PHP Version: 4.3.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Your code is wrong. You should not mix mysql_fetch_row & mysql_result.
Previous Comments:
------------------------------------------------------------------------
[2003-11-05 06:37:08] dario_primorac at net dot hr
Description:
------------
Table employees has 3 colons (name,surname,position).
The table is filled with 3 values.
When the code is executed it forces a endless while loot,
and the browser must be terminated, and my opinion is that
this code sholuld not do that. My opinion is: the mysql_result and
mysql_fetch_row functions are using the same pointer as the handle
(return value). It is my opinion that the while loop will go around
(n,n+1) value where n is number of row fetched by mysql_result
function.
Reproduce code:
---------------
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td></tr>\n",
mysql_result($result,1,"name") , $myrow[1], $myrow[2]);
}
echo "</table>\n";
?>
Expected result:
----------------
Lets say that the table employee was filled with this data:
name surname position
---- ------- --------
Dario Primorac 1
Mario Butijer 2
Vido Vlahinic 3
The result should be:
Name Position
Mario Primorac 1
Mario Butijer 2
Mario Vlahinic 3
Actual result:
--------------
When the code is executed it forces a endless while loot,
and the browser must be terminated.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26136&edit=1