|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Cannot use object of type stdClass as array
I recently moved my site onto a new server that runs PHP 5.0.3 and one of my scripts is now returning an error:
Fatal error: Cannot use object of type stdClass as array in /home/scion/public_html/dealers/add_review.php on line 736 Error Location: http://www.scionlife.com/dealers/add...&sub_cat_id=38 Now I have been trying to research this error using Google, but it just seems to pull up pages that are having the same error, or forums that have mentioned this but their solution was to either switch back to the old version of PHP or to install new software. Those are not options here. I tried to research classes and then trawled through the file looking for bad code, but now I am just more confused: http://www.ocssolutions.com/manuals/...guage.oop.html So, can someone point me in a direction to look -- or offer to fix the code. I'll pay ya $50. ![]() Darren |
|
#2
|
||||
|
||||
|
Stab in the dark: set zend.ze1_compatibility_mode ON. You could try putting a init_set("zend.ze1_compatibility_mode","1"); at the start of your script and see if that helps.
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#3
|
|||
|
|||
|
That looked SO good, but didn't work. By the way, I had to lookup the function because it didn't work at first. The function is actually ini_set() -- but it was a great idea.
Hmmm.... hopefully there is someone that knows! |
|
#4
|
||||
|
||||
|
Can you upload the PHP file here as a textfile upload, or cut-and-paste the offending line 736 along with maybe 10-20 lines before it?
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#5
|
|||
|
|||
|
Sure. I don't think that the offending line is actually the culprit. The offending line is the first line of this batch:
PHP Code:
|
|
#6
|
|||
|
|||
|
Part 1 of file (maximum posts 10,000 chars)
PHP Code:
|
|
#7
|
|||
|
|||
|
Part 2 of file (maximum posts 10,000 chars)
PHP Code:
|
|
#8
|
|||
|
|||
|
Part 3 of file (maximum posts 10,000 chars)
PHP Code:
|
|
#9
|
|||
|
|||
|
Part 4 of file (maximum posts 10,000 chars)
PHP Code:
|
|
#10
|
||||
|
||||
|
My "stab in the twilight" now is the lack of quotes around the array index:
PHP Code:
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#11
|
|||
|
|||
|
Yeah, that was the first thing I tried... but it had no effect. Maybe I will have to go though the entire script changing [variable] to ['variable'] to see if that works. (sigh) I have a feeling it is something more than that, but I will give it a shot.
Darren |
|
#12
|
|||
|
|||
|
Yeah, gave it a shot and it didn't help. There were only two variable names throughout the script lacking quotes: 'error' and 'error_msg'. Fixed them and still getting the error message.
Darren |
|
#13
|
|||
|
|||
|
bump -- $50 to whoever suggest a successful solution.
|
|
#14
|
|||
|
|||
|
A late stab in the dark
This is probably way too late, but i would suggest you try
$results->error_msg instead of $results['error_msg']. As stated, a late stab in the dark, but if you still haven't solved this, it could be worth a try. |
|
#15
|
|||
|
|||
|
I had the same problem, here's the solution.
If dump my array this is what i get: PHP Code:
PHP Code:
This because an stdClass is not an array but an object. To access those values you can do it like this: PHP Code:
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|