|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-11-05 11:15 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 16:00:01 2025 UTC |
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.