Jump to content


Photo

PHP 4 vs. PHP 5


  • Please log in to reply
2 replies to this topic

#1 Mateobus

Mateobus
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 27 October 2006 - 07:57 PM

Hello all,

Issue #1)
I recently switched from a shared hosting plan to a dedicated server. When I switched I switched from php 4 to php 5. All of my scripts seem to run fine, with minimal differences. However, before, if I made a parse error, the error would display on the page, UNEXPECTED ... PARSE ERROR.  Now this no longer happens. If there is a parse error, the page will simply not display. I would like to get the old errors back. Another issue...

Issue #2) My website takes up about 30 gig including everything. I have about 150 gig of server space which recently filled up completely becasue my error_log file got to about 120GB. The error log contains millions of php errors such as undefined var errors which don't stop the scripts from running, just report stupid errors. One example of these errors is an undefined var in an if statement. here is a sample of the code.

page.php?
if ($_GET['some_var'] == '')
 //do something

Well, this creates an error if the some_var variable is not set within the URL. But this is stupid because it works correctly, because if it is not set it is also the empty string '', so it performs as I want it to despite accumulating a 120GB file on my server.  Is there anything I can do about that? Is that in any way related to php 4 vs. php 5.

Issue #3)My scripts, including some that were written in open source by professionals, send out emails automatically (for example to register to a forum). These emails no longer get sent. Is this possibly related to the difference in php versions. Maybe its a firewall thing?

Any help at addressing any one of these issues is appreciated.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 27 October 2006 - 09:35 PM

Sounds like you need to change the error reporting level in your php.ini file to stop it reporting E_NOTICE errors. The alternative is code to avoid the errors in the first place by always checking that a variable is set before trying to access its value.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 28 October 2006 - 11:16 AM

For issue #1 you need to turn your error_reporting level up to E_ALL and turn display_errors on

For issue #2 it is not a stupid error. It actually an error on your part, your syntax is slightly wrong basically. With the following code:
if ($_GET['some_var'] == '')
You are checking the $_GET['some_var'] variables value and not the existence . However if this variable does not exist then PHP will report an undefined variable/index notice (not an error). What you should do is first check for the existence of the variable and then check the value of the variable if it exists. So you'll do something like this:
if(isset($_GET['some_var']) && $_GET['some_var'] == '')
Now when you run your script. PHP will now check for the existance of the $_GET['some_var'] variable first, then if it finds the variable it will now check the value of the variable. Whereas before you are not checking the existence of the variable and so PHP thinks this variable already exists and thus you get the undefined notice message.

If(isset($var)) and if($var) are two completely different things, they are similar but they have different behaviour.

For issue #3 you may need to configure PHP to use your server SMTP Server.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users