Forum Moderators: coopster

Message Too Old, No Replies

Going from php 4.4 to php 5.x

because of web host change

         

andrewshim

3:28 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HI... I am PHP self-taught.
I'm thinking of moving hosts, but the new host is running PHP 5.x while I am currently 4.4.

Do I need to be concerned?

What are the changes I need to make to be compliant to the new web host?

Andrew

dreamcatcher

7:10 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi andrewshim,

I don`t think you have too much to worry about with your code. If you coded for v4.4 it will work in 5. Its the other way around that might have caused an issue as various functions in 5 aren`t compatible with 4.

dc

andrewshim

7:40 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi dreamcatcher...

thanks so much. Actually I now don't have a choice. I am facing a terrible problem which I posted here

[webmasterworld.com...]

Why would my php script that has run fine for so long (2 years) suddenly crash the server as claimed by my web host? Can't be the increase in traffic. I've been hovering on page #1 (google and yahoo!) for months.

eelixduppy

8:20 am on Jan 20, 2007 (gmt 0)



You may want to read up on the Backward Incompatible Changes [us2.php.net] as they may affect your script.

Good luck! :)

cameraman

8:23 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do your scripts expect register_globals to be on? That's the only thing I can think of that would cause problems - like dreamcatcher said, it's generally the other way around that gets sticky.

They'll need to unsuspend you for you to experiment, but if you can stick this at the top of a script:
foreach($_GET as $vbl => $val)
$$vbl = $val;
foreach($_POST as $vbl => $val)
$$vbl = $val;

and see if the script straightens up. If so, then you should remove those lines and go through each script and straighten it out: explicitly grab the variable you're wanting and validate it before use.

andrewshim

8:46 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use the $_GET to get all variables from URL strings.

My former web host techie made a funny change in the code tho... he replaced a couple of [] brackets referring to values in database fields with {} brackets. Why would this make any difference?

cameraman

11:17 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's supposed to be used to dereference individual characters in strings. If you've got:
$vbl = "Howdy";

then echo $vbl{2}; produces
w
and echo $vbl[2]; produces
w

I just checked it and in both php4 and php5, you can do:
$vbl = array("Howdy","hello","goodbye");

and both forms will produce
goodbye

which is not what I expected. But there were no errors. I don't know what to tell you - I'm at a loss. I can't think of any reason that a php4 script would bring down a server when it's run under php5. It would certainly seem reasonable that they could at least say 'well here's what it says in our error logs' to help you pinpoint the problem.

andrewshim

12:52 am on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I've moved to the new web host and all seems fine.

I changed the {curly} back to [square] and no problems...

Then I tested a file without the register globals... and it hung. So I went through every file and made sure they complied with the register globals requirement. All seems okay now...

Fingers and toes crossed!