Re: Object is not instatiated on POST, Fatal error
| From: | Daniel Kullik | Date: | Fri, 02 Jul 2004 10:25:36 +0000 |
| Subject: | Re: Object is not instatiated on POST, Fatal error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189526@lists.php.net to get a copy of this message | ||
You might as well add a reference of your db-object to global scope.
[code]
$GLOBALS['_db_object'] =& $db;
[/code]
Then you could access it anywhere in your code like this:
[code]
$GLOBALS['_db_object']->sumbitQuery($query);
[/code]
Daniel
Angelo Binc2 wrote:
Ok guys, I have fixed the problem and its a really easy fix. basically the object was out of scope and therefore PHP treated my object name as a new variable and therefore it obvioulsy was not set because it is a new variable. SO the way I got it working was to just call the code directly and not put it in a function, or you could pass the object to the function as an argument. Hope this can help others in the future! Angelo-- WWE e-commerce IT GmbH Eiffestrasse 462, D-20537 Hamburg Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50would it be necessary/possible to make it global inside the function? --------------------------------------------------------- http://www.dailymedication.com - Everything you didn't know you needed until you went there and said to yourself, "What did I do before I visited DailyMedication.com?" and another part of you said, "It does not matter.""Jason Paschal" <j_paschal@hotmail.com> 7/2/2004 11:22:04 AM >>>From: "Angelo binc2" <binc2@ctech.ac.za> To: <php-general@lists.php.net> Subject: [PHP] Object is not instatiated on POST, Fatal error Date: Fri, 02 Jul 2004 11:14:53 +0200 Hi all, I have a PHP file. and when it loads it creates an object for my database : include("db_class.inc"); fine. I make a couple of calls to the database class this is also working fine. Then I post the page but to itself and then I go into afunction(lets call it xfunction) which is ONLY accessed once the form hasbeenposted and I get a fatal error: Fatal error: Call to a member function on a non-object in c:\program files\apache group\apache\htdocs\zero\opdocument.php on line 98From what I've read my database object is not instatiated andthereforeis in theory not an object. However I check before I go into the xfunction to see if the object is set and it is, then once in the function (where the error occurs) I test to see if the object is set again and it tells me that the object is not set. What could be the reason for the object not being set once beingcalledin the function (xfunction)?? I have googled and many people get this error but not many have a clear solution. Any help or suggestions will be appreciated. Thanks Angelo -------------------------------------------------------------------- Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php_________________________________________________________________ MSN Life Events gives you the tips and tools to handle the turning points in your life. http://lifeevents.msn.com -------------------------------------------------------------------- Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911