PHP 5 migration issue?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
farmersguide
Forum Newbie
Posts: 4
Joined: Tue Aug 19, 2008 7:25 am

PHP 5 migration issue?

Post by farmersguide »

Hi - Several issues have appeared on a website I manage that may be related to recent migration by our host's servers from PHP 4 to PHP 5.

On one section of the site, the page still operates as expected, but I now get the following notices:
Notice: Undefined variable: searchResults in E:\domains\f\farmersguide.co.uk\user\htdocs\includes\viewcategories.inc.php on line 15

Notice: Undefined variable: htmlCode in E:\domains\f\farmersguide.co.uk\user\htdocs\includes\viewcategories.inc.php on line 15
Line 15 reads:

Code: Select all

<p class="MsoNormal" align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><?=$searchResults?><?php echo $htmlCode; ?></font>
Can anyone confirm if this is a migration issue? And if it is, how might I resolve it?

Many thanks

FG
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: PHP 5 migration issue?

Post by nowaydown1 »

Welcome to the forum! It looks to me that your warning level is set a little higher than you would like. In your PHP configuration file there is an error_reporting directive. I believe you probably want E_ALL & ~E_NOTICE. Right now I would guess you're probably running with just E_ALL.

You can read more about the error_reporting setting here:
http://us.php.net/manual/en/errorfunc.configuration.php

Hope that helps!
farmersguide
Forum Newbie
Posts: 4
Joined: Tue Aug 19, 2008 7:25 am

Re: PHP 5 migration issue?

Post by farmersguide »

nowaydown1 wrote:It looks to me that your warning level is set a little higher than you would like. In your PHP configuration file there is an error_reporting directive. I believe you probably want E_ALL & ~E_NOTICE. Right now I would guess you're probably running with just E_ALL.
Many thanks, you were absolutely right and the pesky notices are no longer an issue.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: PHP 5 migration issue?

Post by jmut »

Not that I want to be picky or something but I strongly suggest you don't remove those noticy by supressing error_reporting. Your best bet is to fix thouse. Other than that you should just have display_errors no on production environment... this will allow for errors/notices or whatever not to be seen but still be logged (if logging enabled of course). By hiding this problem now, you might totally misunderstand a problem in the future that might be related.
farmersguide
Forum Newbie
Posts: 4
Joined: Tue Aug 19, 2008 7:25 am

Re: PHP 5 migration issue?

Post by farmersguide »

jmut wrote:I strongly suggest you don't remove those noticy by supressing error_reporting. Your best bet is to fix thouse.
It certainly occurred to me that hiding the issue was second-best to fixing it, but as a site manager with a boss demanding that the notices be removed because it affected the user experience, it was a useful first step.
As a postscript, it emerged that the notices - and several othe problems - were all related to a PHP4 to PHP5 upgrade by our webhosts late last week. The original site developer was persuaded to fix all the issue and as of this morning everything is working properly again.
Corvin
Forum Commoner
Posts: 49
Joined: Sun Dec 03, 2006 1:04 pm

Re: PHP 5 migration issue?

Post by Corvin »

farmersguide wrote:As a postscript, it emerged that the notices - and several othe problems - were all related to a PHP4 to PHP5 upgrade by our webhosts late last week.
The notice appeared because your PHP4 installation was configured to surpress notices, but not your PHP5 installation. The notice appears when you do this for example:

Code: Select all

$i++;
instead of

Code: Select all

$i = 0;
$i++;
So your lazy developer caused the notice and not the PHP update. :)

Btw. you should change your webhoster since he seems not to be aware of security risks.
farmersguide
Forum Newbie
Posts: 4
Joined: Tue Aug 19, 2008 7:25 am

Re: PHP 5 migration issue?

Post by farmersguide »

Corvin wrote: you should change your webhoster since he seems not to be aware of security risks.
Thanks for the advice - that's definitely something that's under consideration.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: PHP 5 migration issue?

Post by jmut »

Just configure display_errors directive to be off in live environment. thats all. Users will never see problems. At very worst (fatal error) they will see blank screen. But you examining the logs will see it all (including notices etc). So bottom line:
1. Always have error_reporting (E_ALL) unless using some weird 3rd party lib that is <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> and you can't fix and don't want log cludge. For those I usually make wrapper that I can easily lower error_reporting only when calling specific method from 3rd party lib..and back to E_ALL then.
2. Have display errors off in production and enabled logging. Better in project dir than in server /tmp folder...those might get lost ;)
Glad you solved issue.
Post Reply