PHP5 Database Upgrade

March 8th, 2008 | Author: Chip

My hosting company is performing database upgrades, PHP4 to PHP5, and MySQL4 to MySQL5. That’s a great news, but I had some hard times updating my old scripts (that is from my clients’ web sites). I did some research and I lost several nights to update all my scripts.

Here’s some quick tips:

1. Lets’s start with the short tags which are off by default, so instead of <? ... ?> use <?php ... ?>

2. register_globals is off by default, too. This setting defines whether a variable from $_POST, $_GET or $_COOKIE is automatically recognized in your scripts, so you should change code like this:

if (isset($_POST['something'])) $something=$_POST['something'];

3. The default setting for magic_quotes_gpc in PHP4 was on, but in PHP5 the option is off by default. This mean that any user input from forms etc that was previously having any embedded quotes automatically escaped with backslashes, will not be treated this way. If your code was written with portability in mind this might already be taken care of, but if you were relying on magic quotes then any user input like O’Reilly will give you problems.

4. PHP 5 might get a bit funny about some OOP notation, and passing references at calltime. However, in the majority of situations, it will just emit an E_NOTICE or an E_WARNING error, and carry on as normal.

5. Use $_SERVER['PHP_SELF'] instead of 'PHP_SELF'.

3 comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled
Get Adobe Flash playerPlugin by wpburn.com wordpress themes