php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30630 Error message: Call to a member function on a non-object
Submitted: 2004-10-31 18:22 UTC Modified: 2004-11-29 01:00 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: boccara at netvision dot net dot il Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 4.3.9 OS: win 2K / apache 2.0.49
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-31 18:22 UTC] boccara at netvision dot net dot il
Description:
------------
Hello I have a defined a class that manage a 2 dimensions array (table).
I have created 2 oblect of this class.
These oblect are inside a loop , a fetch from an sql query (MSSQL).
The oblects received data from the query.
Teh problem is that after a certain number of times in the loop ( always the same number of times depending to the query), I got an error message:
Call to a member function on a non-object

when are called the function of the created object.
This is very strange, the created object seems to be deleted !!

I use Zend Studio, I use the debugger to search the bug, but there is no syntax bug or anything else !?



Reproduce code:
---------------
class TotDevisParEditeur
{
	var $VecEditeur = array();
	var $value = array();

	function GetValue($type,$editeur)
	{
		return 	$this->VecEditeur[$editeur][$type];
	}

	function Display($type,$editeur)
	{
		echo $this->VecEditeur[$editeur][$type];
		endl();
	}

	function AddDevis($type,$editeur,$numOfdevis)
	{
		$value[$type] = $this->GetValue($type,$editeur) + $numOfdevis;

		$this->VecEditeur[$editeur] = $value;

		$this->Display($type,$editeur);
	}
}

/////////////////////////////////////////////////////////

$SousTotal = new TotDevisParEditeur;
	$SousTotalCom = array();
	$SousTotalCom['gagne'] = new TotDevisParEditeur;
	$SousTotalCom['perdu'] = new TotDevisParEditeur;
	$SousTotalCom['encours'] = new TotDevisParEditeur;

	
		
while (dbFetch($iTableTmp, $Col))
{
/*
in this portion of code there is no redefinition of the object !!
just value are assigned to $RefEditeur, $Gagne,...
*/

$SousTotal->AddDevis('gagne',$RefEditeur,$Gagne);
		$SousTotal->AddDevis('perdu',$RefEditeur,$Perdu);
		$SousTotal->AddDevis('encours',$RefEditeur,$Encours);
	
		$SousTotalCom['gagne']->AddDevis($Gestionnaire,$RefEditeur,$Gagne);
		$SousTotalCom['perdu']->AddDevis($Gestionnaire,$RefEditeur,$Perdu);
		$SousTotalCom['encours']->AddDevis($Gestionnaire,$RefEditeur,$Encours);

}



Expected result:
----------------
.... results .....

************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>
************************
instead of the error it should continue !!!!!!!!!!!!
*************************

Actual result:
--------------
last section of the result 

************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>

Fatal error: Call to a member function on a non-object in c:\Program Files\Apache Group\Apache2\htdocs\speedevis\lib\StatRev.inc.php on line 2018


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-31 19:04 UTC] boccara at netvision dot net dot il
Zend Studio Server  3.5.0
 
 Zend Server Center  3.5.0    
 
 Zend Engine  1.3.0    
 
 PHP  4.3.9    
 
 Zend Optimizer  2.5.5    
 
 Zend Debugger  3.5.2    
 
 Zend Extension Manager  1.0.4 


I also made a test with the Zend Optimiser on OFF and no change difference , still the fatal error .....
 [2004-10-31 21:20 UTC] boccara at netvision dot net dot il
dbfetch us an function created to choose a fetch according to the database.
in our case it is MSSQL.
this function works already since 4 years.

Function dbFetch ($iResult, &$tabColonne) {

  $iNbCol = 0; // Permet de recuperer une erreur ou le nombre de colonnes
  $tabColonne = array();
  switch (SGBD) {

    case "ODBC":
      	$iNbCol = odbc_fetch_into($iResult, &$tabColonne);
      break;

    case "MSQL":
	$tabColonne = mysql_fetch_row($iResult);
        if($tabColonne) $iNbCol = count($tabColonne);
      break;

    case "MSSQL":
	$tabColonne = mssql_fetch_array($iResult);
    if($tabColonne)
    {
    	$iNbCol = count($tabColonne);
    }
     break;
  }
  return $iNbCol;
}
 [2004-10-31 21:23 UTC] boccara at netvision dot net dot il
the line 2018 in the fatal error is:

$SousTotal->AddDevis('gagne',$RefEditeur,$Gagne);
 [2004-10-31 21:45 UTC] boccara at netvision dot net dot il
function endl()
{
echo "<br>";
}
 [2004-11-01 00:33 UTC] derick@php.net
Remove all the zend extensions from your configuration, and try again. Only disabling them is not good enough!
 [2004-11-01 21:03 UTC] derick@php.net
Please make a short reproducing script (max 15 lines if you can).
 [2004-11-01 22:10 UTC] boccara at netvision dot net dot il
If I could I would be short but this bug is quite strange so I gave you a part of the code and part of the result.
The result is explained in a few line, you don't have to read the 300 lines !!.
I lost a lot of time because of this possible bug, so please take at less 5 mn to read my explains.
thank you.
 [2004-11-11 14:00 UTC] tony2001@php.net
Please, simplify your reproduce script as much as possible. 
I'm unable to get where the bug is and your explanations do not help much.
 [2004-11-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC