php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28194 internal referencing of array entry seems flawed
Submitted: 2004-04-27 22:34 UTC Modified: 2004-05-05 22:40 UTC
From: email at philbert dot nl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-04-27 22:34 UTC] email at philbert dot nl
Description:
------------
class RSSitem
{
  var $dblink;
  var $success = false;
  var $items;
  var $currentItem;

  function RSSitem($pDBname, $pUsername, $pPassword)
  {
    $this->$dblink = mysql_connect("localhost:3306",$pUsername, $pPassword);

    if (mysql_select_db($pDBname, $this->$dblink))
    {
        $query = "select id " .
                 "     , title " .
                 "     , description " .
                 "     , guid " .
                 "     , link " .
                 "     , pubDate " .
                 "from item " .
                 "order by id desc";

        $this->$items = mysql_query($query, $this->$dblink);
        if ($this->$items) 
        {
            $this->$currentItem = mysql_fetch_assoc($this->$items);
            if ($this->$currentItem)
            {
                $this->success = true;
                //print_r($this->$currentItem);
            }
        }
     }
  }

  function title()
  {
    $value = $this->$currentItem["title"];
    return $value;
  }
}

When an object of class RSSitem is made, and the function object.title() is called, it returns the entire array $this->$currentItem, instead of entry ["title"] of this array.
When I rewrite the function thus:
  function title()
  {
    $temparray = $this->$currentItem;
    $value = $temparray["title"];
    return $value;
  }
it does work.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-28 09:07 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
 [2004-05-01 13:13 UTC] email at philbert dot nl
When hardcoding an array, this problem does not seem to appear, so it seems related to the use of database functionality.

Is there a way to create a lifelike result resource without actually using a database?
 [2004-05-05 22:40 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 21:01:32 2024 UTC