php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2843 Cannot use variable after a mysql_fetch_array
Submitted: 1999-11-27 13:05 UTC Modified: 2000-03-18 09:33 UTC
From: yzhang at sfu dot ca Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yzhang at sfu dot ca
New email:
PHP Version: OS:

 

 [1999-11-27 13:05 UTC] yzhang at sfu dot ca
Assuming $qid is a valid result of a mysql_query:

while ($r = mysql_fetch_array($qid)) {
    ...do something...
}

$r["foo"] = "bar";
echo $r["foo"];

Will not display anything.  $r["foo"] is never assigned the value "bar".  Instead, I must forcefully unset($r); or $r = array; before trying to make the $r["foo"] = assignment.

This works fine in PHP 3 but not in 4.0 beta 3.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-18 09:33 UTC] zeev at cvs dot php dot net
Fixed.  Thanks for the report!
 [2023-10-10 09:09 UTC] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/doc-en/commit/a11c5b53bc132289a0ddcc6d3efee5d97f0027b4
Log: Fixed #2843: Error section mistakingly called the previous situation 'Exception' instead of warning
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC