Forum Moderators: coopster
I have an oscommerce site and have installed a newsletter products contribution as directed by the developer but have come up with problems. Understandably the developer is very busy and has not been able to get back to me, I have searced oscommerce site for answers and experts exchange and although help is excellent, it doesn't come very fast and I don't mean that in a nasty way, just that this has taken days!
the error message i was getting was:
Warning: reset() [function.reset]: Passed variable is not an array or object in /home/example/public_html/store/admin/includes/classes/object_info.php on line 17
Warning: Variable passed to each() is not an array or object in /home/example/public_html/store/admin/includes/classes/object_info.php on line 18
i was advised:
change the objectInfo() function to the following. Then, it will tell you exactly where in the code the bad call is being made:
function objectInfo($object_array) {
if (!is_array($object_array) &&!is_object($object_array)) {
echo "*** ERROR FOUND ***";
var_dump($object_array);
debug_print_backtrace();
die();
}
reset($object_array);
while (list($key, $value) = each($object_array)) {
$this->$key = tep_db_prepare_input($value);
}
}
I did this and this is what I got:
*** ERROR FOUND ***bool(false) #0 objectInfo->objectInfo() called at [/home/example/public_html/store/admin/newsletters.php:229]
I was advised:
What's happening at /home/example/public_html/store/admin/newsletters.php on line 229?
Keep doing this style of debugging, until you find something that doesn't make sense. Probably there is some database call that is trying to initialize the object with 0 records.
And now I'm stuck!
I have looked at the code at /home/example/public_html/store/admin/newsletters.php on line 229 but because I don't understand a thing about it, although I really have tried, I don't even know what I am looking at.
Can anyone help please?
Thank you in advance
[edited by: dreamcatcher at 2:07 pm (utc) on Nov. 14, 2007]
[edit reason] Removed specifics. [/edit]
Hopefully the problem will be from $newsletter.
Thanks for your reply. Could you have a look at these two pages for me to see if the problem is there as I don't know what I'm looking at. I'd be very grateful.
<removed large code dump as it is not needed>
thanks very much for your help
[edited by: eelixduppy at 11:07 pm (utc) on Nov. 14, 2007]
To save the mods some work you should remove all links when you post the code, as you will find everything gets turned into example.com. Dont worry every one forgets at some point.
The report that you are getting from the debug_backtrace is not mentioning any included files...however that doesnt always mean that the problem doesnt stem originally from an included file.
The var_dump is saying that there is nothing in the $newsletter variable. So that is your problem, however why it is blank is another question.
The first php file is just a load of constants that are getting defined for use everywhere. There should be an include 'constants.inc'; at the top to make sure those constants are getting passed along to the other pages. As you dont have that at the top of the other code you posted so is there other included/required(_once) files listed?
You are looking for a group of code that starts with -
class <some_name> {
function objectInfo($something) {
...
}
in any other included files. This may be a class called objectInfo, in which case as you are trying to add content to its contructor you would need to call it in a different way -
$nInfo = new objectInfo($newsletter); Although this only helps when there is actually something in $newsletter ;)
Also it may be quicker to ask the people that wrote the code. Although I am assuming this is old code as it is using the $HTTP_GET_VARS as opposed to $_GET, so there may well be an up-to-date version of the code around. Not that $HTTP_* are wrong, just depreciated old form.
Also the code that you posted was not the set of code from the file with the original error on line 229. So in that file are there other included files, or the class that objectInfo belongs to.
It may be worth adding error_reporting [uk3.php.net](E_ALL); to the top of all of your pages while you test. As this will hopefully help you with any errors that may not be getting through to you. Also if you see @ before any functions then remove it while testing as this is used to mute errors, so there may be others errors hiding that will help you sort out this one.
Start with this from the manual - [php.net...]