php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #96 ereg and array bugs
Submitted: 1998-02-20 21:09 UTC Modified: 1998-02-20 22:16 UTC
From: walshj at ns dot net Assigned: rasmus (profile)
Status: Closed Package: Parser error
PHP Version: 3.0b3 OS: Solaris, SPARC
Private report: No CVE-ID: None
 [1998-02-20 21:09 UTC] walshj at ns dot net
The following snippet always generates

   Parse error: parse error in 
   /home/virtual/muwupa/update.php3 on line 83

>> CODE SNIPPET <<

78 $pwdfile = @file($htpasswd);
79 $fp = fopen($htpasswd, "w");
80
81 for ($i = 0; $i < count($pwdfile); $i++) {
82    echo "delete: ", $delete, "; pwdfile: ", $pwdfile[$i];
83    if (!(ereg($delete, $pwdfile[$i], $t)) {
84       $temp = $pwdfile[$i];
85       fputs($fp, $temp);
86    }
87 }
88
89 fclose($fp);

>> END SNIPPET <<

The numbers in front of each line of code are the corresponding line numbers.  Seems like a bug in ereg.  The syntax according to PHP/FI 2 and PHP3 says that it should be fine.

Also the following code seemed to have a bug in $deluser.  When echoing out deluser, as below, it said that the value of deluser was "Array" rather than the real value of "test2"

>> CODE SNIPPET <<

78 $pwdfile = @file($htpasswd);
80 $fp = fopen($htpasswd, "w");
81
82 for ($i = 0; $i < count($pwdfile); $i++) {
83    $deluser = explode(":", $pwdfile[$i]);
84    echo "deluser: ", $deluser, "; delete: ", $delete, "; pwdfile: ", $pwdfile[$i];
85    if ($deluser[0] != $delete) {
86       $temp = $pwdfile[$i];
87       fputs($fp, $temp);
88    }
89 }
90
91 fclose($fp);

>> END SNIPPET <<

I'd be happy to email the three files that comprise the entire PHP application if anyone is interested.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-02-20 22:16 UTC] rasmus
Missing a ) on line 83 of the first snippet and on line 84 of the second you need to use $deluser[0]
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 19:01:28 2024 UTC