Re: Warning messages on web page.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 22, 2010 at 03:17:53PM +0100, Mike Davies wrote:

> Hello,
> 
> This is my first post to this list and I am a novice at php coding. I
> can generally follow the code but not good at writing from scratch.
> 
> 
> I have recently been trying to add to a website which was originally
> developed by someone else and is written in php and mysql. I am trying
> to add a 'news' section to the site. This would be similar to an
> existing 'projects' section so, rather than write it completely from
> scratch I copied the php and the database tables from the 'project'
> section and renamed 'project' to 'news'.
> 
> 
> This is working well except for one thing – I get the following error
> messages when looking at the detailed news item. This code does not
> produce this warning in the project section which is using the same php
> code
> 
> 
> Warning: reset() [function.reset]: Passed variable is not an array or
> object in /home/b23aadf/public_html/news/details.php on line 72
> 
> Warning: Variable passed to each() is not an array or object
> in /home/b23aadf/public_html/news/details.php on line 73
> 
> 
> The relevant lines are :
> 
> 
> 72 reset($thumbsarray);
> 
> 73 while (list($key, $value) = each($thumbsarray)) {
> 
> The site is at www.aadf.co.uk and select 'News'.
> 
> Is anyone able to help resolve this? If you let me know what further
> information you require I can provide it.

Well formed question. Thanks for that. I see too many which aren't.

I can't say why it's happening, but the $thumbsarray variable isn't
getting built the way it should. You can insert a line just before your
errors pop up like:

<?php echo '$thumbsarray: '; print_r($thumbsarray); ?>

or

<?php echo '$thumbsarray: '; echo var_dump($thumbsarray); ?>

or something similar. This will tell you if the variable is set and what
type it has. I'm guessing it's not set. You'll have to look earlier to
see where it should be built and isn't.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux