Jump to content

Recommended Posts

Posted (edited)

PHP Help.

 

Our website error log is being hammered as there seems to be problems with our classPage.php file. Could someone have a look why the following errors are happening. We didn't create the website and now the company are not so helpful. The log file expanded to over 13GB because of these errors, it has been cleared and since this morning over 8000 have been relogged.

 

Attached is the classPage.php classPage.php.txt

 

The most common errors are:

 

PHP Notice:  Undefined index: chrSchoolName in /httpdocs/includes/classPage.php on line 175
PHP Notice:  Undefined index: chrSchoolName in /httpdocs/includes/classPage.php on line 49
PHP Notice:  Undefined index: chrURL in /httpdocs/includes/classPage.php on line 18
PHP Notice:  Undefined index: dtTimestamp in /httpdocs/includes/classPage.php on line 80
PHP Notice:  Undefined variable: html in /httpdocs/includes/classPage.php on line 187
PHP Notice:  Undefined variable: html in /httpdocs/includes/classPage.php on line 223
PHP Notice:  Undefined variable: html in /httpdocs/includes/classPage.php on line 293
PHP Notice:  Undefined variable: html in /httpdocs/includes/classPage.php on line 324 (Most common error)
PHP Notice:  Undefined index: idPageLive in /httpdocs/includes/classPage.php on line 295 (Most common error)
PHP Notice:  Undefined variable: list in /httpdocs/includes/classPage.php on line 1077
PHP Notice:  Undefined variable: txtGlobalKeywords in /httpdocs/page.php on line 94
PHP Notice:  Undefined variable: onload in httpdocs/page.php on line 123
PHP Notice:  Undefined variable: sql2 in /httpdocs/includes/classPage.php on line 1102
PHP Notice:  Undefined variable: txtBody in /httpdocs/includes/classPage.php on line 1115
PHP Notice:  Undefined variable: txtBody in /httpdocs/includes/classPage.php on line 802

 

If anyone can help, we'd be most appreciated. It'll probably help cure our website being so slow too.

 

Thanks,

 

Michael

Edited by linkazoid
Posted

From what I can see it looks like the file is coded to work with an older version of php. What version of php are you running currently since I expect this may work better on php 5.2 if your not running that already so it's worth giving that a try however you could add the following to the affected file which would suppress the errors until you can resolve the issue fully:

 

error_reporting(0);

 

Is this website your live school website and if so is it a custom build or is it based in something like Joomla.

 

Edit: Just to add to the above, setting error reporting to 0 isn't good practice so do not do that for a permanent solution.

Posted

It's a custom CMS called apparently called DASH.

 

I've read about suppressing the errors but wanted to try to solve the root issue first. It's hosted on LGfL and I think it's php 5.4 and it is the live site.

 

Are the errors not caused by the variables not being declared? Or are they declared properly?

 

Thanks for your reply.

Posted

Unfortunately I'm not the best when it comes to coding php and without access to the website in question I'm can't test it myself to debug it. That said from what I can see the code may simply need some changes so that it checks to see if the variable is set or null. This is done by adding php isset into the code which is shown here:

 

PHP: isset - Manual

 

I expect if you add that in correctly it should stop the errors as it will check to see if the variable is null and then ignore it the result is in fact null. Sorry if this doesn't make much sense (i'm bad at explaining code lol) but has php always been 5.4 on the website or was it recently updated since I have seen websites that still work after a php upgrade but start spitting out errors since the syntax in the new php version requires certain checks that the older versions didn't.

  • 2 weeks later...
Posted

I would start by changing line 18.

From:

if($_REQUEST['chrURL']){

To:

if((isset($_REQUEST['chrURL']) && ($_REQUEST['chrURL'])){

 

See if that reduces a few of the errors to start with, or just that one. Also comment out line 1102 (add // at the beginning of the line)

Posted (edited)

Hi Rob,

 

If I change line 18 to the one you posted, then the site does not load. I have now commented out line 1102.

 

Regards,

 

Michael

 

Edit: noticed that the was one ) missing from your change. Have corrected it and now the site is loading with both of your changes. I will see what continues to fill the error.log

Edited by linkazoid
Posted

Hi @RobTrehy

 

I have looked at the logs today and lines you fixed are no longer showing. :)

 

It still is being hammered with the majority coming from:

PHP Notice: Undefined variable: html in /httpdocs/includes/classPage.php on line 324

PHP Notice: Undefined index: idPageLive in /httpdocs/includes/classPage.php on line 295

 

If you are able to help resolve these too that would be amazing!

 

Thanks,

 

Michael

Posted
@linkazoid the html error on line 324, the code starts adding data to a variable $html, ($html .= "content goes here") but the $html variable doesn't exist first. If you can try, add a new line under line 322 and make it $html = ""; save that and then see if the error still comes up.
  • Thanks 1
Posted (edited)

A massive massive thanks to @chris_uk, he has sorted out all our php errors in a few back and forth emails whilst I've been trying to get "42Squared.con" to fix it for 2 years!

 

A fine example of what this forum us about, he went above and way beyond what I was hoping would be resolved!

 

Also, thanks to the others who helped too! :)

Edited by linkazoid
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...