Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 785 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Call to a member function read() on a non-object..

Thread title: Call to a member function read() on a non-object..
Closed Thread    
    Thread tools Search this thread Display Modes  
12-17-2007, 12:52 PM
#1
getout is offline getout
Status: Junior Member
Join date: Sep 2005
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 0%
 

getout is on a distinguished road

  Old  Call to a member function read() on a non-object..

Hi,

I am trying to make a xml-rpc client & server for the oscommerce script. but when i m trying to invoke it, it is giving me this error

Code:
PHP Fatal error:  Call to a member function read() on a non-object in C:\\Program Files\\EasyPHP 2.0b1\\www\\oscommercev3\\includes\\classes\\database.php on line 487
Line 487 of database.php is this

PHP Code:
function execute() {
      global 
$osC_Cache;

      if (isset(
$this->cache_key)) {
        if (
$osC_Cache->read($this->cache_key$this->cache_expire)) {
          
$this->cache_data $osC_Cache->cached_data;

          
$this->cache_read true;
        }
      } 
There is a file application_top.php which instantiate $osC_Cache.

when i include application_top.php in normal php functions file, it works perfectly but when i use in xmlrpc server file then it gives me above error.

Can anybody suggest me a solution??

12-17-2007, 04:18 PM
#2
Xeoncross is offline Xeoncross
Status: I'm new around here
Join date: Dec 2007
Location:
Expertise:
Software:
 
Posts: 19
iTrader: 0 / 0%
 

Xeoncross is on a distinguished road

  Old

PHP is saying that there is NO function called "read" in the "$osC_Cache" object. So my guess is that your xml-rpc is not including the "$osC_Cache" object file the right way.

I recommend a var_dump or something to see if $osC_Cache is empty. If it is, you will know you need to check your require()/include() code. Also, If the file that makes the $osC_Cache obj is not being included - it won't even be an obj - just a null variable.

12-17-2007, 04:25 PM
#3
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

no I dont do PHP at all and im a .net guy but I thought that error means that the object hasnt been instantiated (sp?) yet.

You need to create a new instance of the object. now i have NO idea wha the hell global $x means. lol

how do i know this: i was debugging oscommerce for a friend yesterday. this guy has a done a lot for me ,and even i know i have no idea for php i decided to take a look at it. I think i broke it, but fixed it temp.

I was getting that same error (different file, line) though, and i looked at it and it said

if something = true {
$x = new y
}

$x -> blah.

and i just took the if statement out and it worked lol

12-17-2007, 04:36 PM
#4
Xeoncross is offline Xeoncross
Status: I'm new around here
Join date: Dec 2007
Location:
Expertise:
Software:
 
Posts: 19
iTrader: 0 / 0%
 

Xeoncross is on a distinguished road

  Old

Originally Posted by masfenix View Post
no I dont do PHP at all and im a .net guy but I thought that error means that the object hasnt been instantiated (sp?) yet.
Yes, that is what I said. If there is no function read() in that object AND YOU KNOW FOR A FACT THERE SHOULD BE - then that means the object was not created and so you didn't included the file that makes it.

in other words,

PHP Code:
$osC_Cache null

Also masfenix, "global" means bring a variable/obj/array from outside the function - inside so that function can work with it.

12-17-2007, 05:08 PM
#5
getout is offline getout
Status: Junior Member
Join date: Sep 2005
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 0%
 

getout is on a distinguished road

  Old

There is application_top.php file which is initializing osC_Cache

PHP Code:
require('include/classes/cache.php');
$osC_Cache = new osC_Cache(); 
the problem is when i include application_top.php in normal plain php file, it initialize osC_Cache & works perfectly but when i put same file in my xmlrpc server.php file it give me this error.

12-17-2007, 05:23 PM
#6
Xeoncross is offline Xeoncross
Status: I'm new around here
Join date: Dec 2007
Location:
Expertise:
Software:
 
Posts: 19
iTrader: 0 / 0%
 

Xeoncross is on a distinguished road

  Old

Well, you have to look back over your require('include/classes/cache.php'); code because some how that obj is NOT being created.

Is there anything that might over-write it?
Did you try a var_dump to see what that obj had in it by the time it makes it to your code?
Did you try making a "core.php" that every script calls that will handle all the included for your files? Like:
PHP Code:
<?php

require($db);
require(
$file1);
require(
$file2);
...
?>
So all files will have the same way of including?

12-17-2007, 06:00 PM
#7
Bursh. is offline Bursh.
Status: Member
Join date: Nov 2006
Location: In your bath.
Expertise:
Software:
 
Posts: 121
iTrader: 0 / 0%
 

Bursh. is on a distinguished road

Send a message via AIM to Bursh. Send a message via MSN to Bursh.

  Old

My tip - When trying to debug something echo\print EVERY variable from inside the method to see if the values are what you expected. If they - Echo every variable from OUTSIDE the method to see if it's what you expected.

12-18-2007, 03:35 AM
#8
Xeoncross is offline Xeoncross
Status: I'm new around here
Join date: Dec 2007
Location:
Expertise:
Software:
 
Posts: 19
iTrader: 0 / 0%
 

Xeoncross is on a distinguished road

  Old

echo/printing is useless on Objects.

Use var_dump: php.net/var_dump

12-18-2007, 06:29 AM
#9
getout is offline getout
Status: Junior Member
Join date: Sep 2005
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 0%
 

getout is on a distinguished road

  Old

ok now that problem is solved, but having other problem

Code:
XML error at line 1, check URL
here is the details

Code:
<?xml version="1.0"?>
<methodCall>
<methodName>xxxx.getXxxx</methodName>
<params>
</params>
</methodCall>

---SENDING---
POST /oscommercev3/xml_server.php HTTP/1.0
User-Agent: XML-RPC for PHP 2.2
Host: localhost:80
Accept-Encoding: gzip, deflate
Accept-Charset: UTF-8,ISO-8859-1,US-ASCII
Content-Type: text/xml
Content-Length: 109

<?xml version="1.0"?>
<methodCall>
<methodName>xxxx.getXxxxx</methodName>
<params>
</params>
</methodCall>
---END---

---GOT---
HTTP/1.1 200 OK
Date: Tue, 18 Dec 2007 06:20:45 GMT
Server: Apache/2.2.3 (Win32) PHP/5.2.0
X-Powered-By: PHP/5.2.0
Set-Cookie: language=en_US; expires=Mon, 17-Mar-2008 06:20:46 UTC; path=/oscommercev3/; domain=localhost
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 759
Connection: close
Content-Type: text/xml

‹�������Ù&ýint(6)
‹������³±¯ÈÍQ(K-*ÎÌϳU2Ô3P²·ã²ÉM-ÉÈO	J-.ÈÏ+N
$%æÃ@º,1§4ÕÎ&3¯ÄÎÌFDÙèCĸlôaŠôáÚôÑL�Ý;x���int(6)
‹������mSÛn£0}ÏWdû´«*r!*«´Cœ	á-Æ,NÊM�†¤_¿N"VUÕ§3Ï™sÆ#O_ÏYÚ=ÅÇj_äσßÒÃëKgú£×ë:ˆ»:Ô<³‹,cÝý©©œŒ»Ðkê¿þt—êˆ%Å»"84ýØTh¦Qn•t8Vо¯êo’â‰úDڙʛ=4*ª�s�2“ŸB(sê{�td�í@+—K™Á-ZœéÍ©å¹™Q‡®àÍ4‰8ú1Pšm0ç4X=
ýÓW�›?O†7I‰°gˆ©Ðä#Pmû,¥¹-ÎB®’0S.ÈÐ�ÔËò€$†ÄYï5$<J+:´8Þ£‘=Yëêçm;´Òhf×Ø—tˆKšEd²É.P+dâ4ÌÎœ™Þ·{ȹx»”éEB6—nR9ÄÚ[î[½rÎÄ»4O²æŽýih�hŽ¯³Ôd–6¡[$Ì$c”1õ›ÏZ:ÊRèËÒÒ;§4cÒNh*\UIq\\jÛ&s{¶ˆ«ÅuŸQ®h`åëCù7	o†òÁLC
�«×9��d�€šÌG�ýóiëÛ9Ò¥Geâ¦{5A€Õa€ñï[�Î/ª²Ù«ù·;QËiw{ï§	2�‹Ø½ŒÀM³\^s@ÍC“ì™ÝëtµåÚYƒ–#Ó»ß&…—–#^Ó›Ö[	öÕq!‘5›â¹Óë‰_�Å5/Ž«²È«X$ÊÝq—Um ð´Kßã—é>¯_&Óþ¦ý{®3í·Eýÿ´þ—ŽÿôÔÎç~�����ÿÿ�0ãºÔÙ��
---END---

HEADER: date: Tue, 18 Dec 2007 06:20:45 GMT
HEADER: server: Apache/2.2.3 (Win32) PHP/5.2.0
HEADER: x-powered-by: PHP/5.2.0
HEADER: set-cookie: language=en_US; expires=Mon, 17-Mar-2008 06:20:46 UTC; path=/oscommercev3/; domain=localhost
HEADER: expires: Thu, 19 Nov 1981 08:52:00 GMT
HEADER: cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
HEADER: pragma: no-cache
HEADER: vary: Accept-Encoding
HEADER: content-encoding: gzip
HEADER: content-length: 759
HEADER: connection: close
HEADER: content-type: text/xml
COOKIE: language=en_US

---INFLATED RESPONSE---[729 chars]---
int(6)
‹������³±¯ÈÍQ(K-*ÎÌϳU2Ô3P²·ã²ÉM-ÉÈO	J-.ÈÏ+N
$%æÃ@º,1§4ÕÎ&3¯ÄÎÌFDÙèCĸlôaŠôáÚôÑL�Ý;x���int(6)
‹������mSÛn£0}ÏWdû´«*r!*«´Cœ	á-Æ,NÊM�†¤_¿N"VUÕ§3Ï™sÆ#O_ÏYÚ=ÅÇj_äσßÒÃëKgú£×ë:ˆ»:Ô<³‹,cÝý©©œŒ»Ðkê¿þt—êˆ%Å»"84ýØTh¦Qn•t8Vо¯êo’â‰úDڙʛ=4*ª�s�2“ŸB(sê{�td�í@+—K™Á-ZœéÍ©å¹™Q‡®àÍ4‰8ú1Pšm0ç4X=
ýÓW�›?O†7I‰°gˆ©Ðä#Pmû,¥¹-ÎB®’0S.ÈÐ�ÔËò€$†ÄYï5$<J+:´8Þ£‘=Yëêçm;´Òhf×Ø—tˆKšEd²É.P+dâ4ÌÎœ™Þ·{ȹx»”éEB6—nR9ÄÚ[î[½rÎÄ»4O²æŽýih�hŽ¯³Ôd–6¡[$Ì$c”1õ›ÏZ:ÊRèËÒÒ;§4cÒNh*\UIq\\jÛ&s{¶ˆ«ÅuŸQ®h`åëCù7	o†òÁLC
�«×9��d�€šÌG�ýóiëÛ9Ò¥Geâ¦{5A€Õa€ñï[�Î/ª²Ù«ù·;QËiw{ï§	2�‹Ø½ŒÀM³\^s@ÍC“ì™ÝëtµåÚYƒ–#Ó»ß&…—–#^Ó›Ö[	öÕq!‘5›â¹Óë‰_�Å5/Ž«²È«X$ÊÝq—Um ð´Kßã—é>¯_&Óþ¦ý{®3í·Eýÿ´þ—ŽÿôÔÎç~��
---END---

XML error at line 1, check URLAn error occured :Code: 2 Reason: 'Invalid return payload: enable debugging to examine incoming payload (XML error at line 1, check URL)'
in the respone the first int(6) is coming because i m having a var_dump line in code. it is correct response, but how can i know what else is coming with it?

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed