PHP 4 -> 5 problem.

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
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

PHP 4 -> 5 problem.

Post by Disent »

Hi, i have a problem while changing PHP 4 code to work on PHP 5.
If anyone is willing to help me out a bit please add me to msn. file[dot]syntax[at]hotmail[dot]com

Thanks.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP 4 -> 5 problem.

Post by Chris Corbyn »

This is not what our web forum is for. I'm also not convinced you'll get much help by asking people to MSN you in order to help you. Please post your problem here so others can help you and so that (possibly) in future others can be helped by reading your problem with its solution.
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

Ok sorry.

in php 5 get_class has to be changed to strtolower(get_class($str))

but after i do the change one of the files gives me an error because of a function. (first line of it)

Code: Select all

function BreakString($strText, $intMaxLength, $strSuffix = "") {
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP 4 -> 5 problem.

Post by Chris Corbyn »

Disent wrote:Ok sorry.

in php 5 get_class has to be changed to strtolower(get_class($str))

but after i do the change one of the files gives me an error because of a function. (first line of it)

Code: Select all

function BreakString($strText, $intMaxLength, $strSuffix = "") {
What is the error it gives you?
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

It gives me a an error that actually points to a different file but im pretty sure the error is there because i traced.

anyway this is what the error referes to:

foreach ($engSystem->arrStructure[INTERFACE_NAME][$engUser->fnGetParam("level")] AS $tmpKey => $tmpItem) {

"level" seems to be empty...


Warning: Invalid argument supplied for foreach() in index.php on line 30
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP 4 -> 5 problem.

Post by Chris Corbyn »

I'm really sorry but you're talking in riddles ;) Could you please elaborate on the exact nature of your problem? Posting these tiny little excerpts of code is telling me nothing at all since I have no idea what that code is supposed to do and/or what's not working. If you're getting an error message please post the exact error message here. if you're not getting an error but something isn't working, please start from the beginning, explaining what *should* be happening, but describing what *is* happening. Also post as much code as you think is relevant... not just these partial lines.

You need to help us understand your problem before we can help you ;)
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

It's a whole costum CMS system.
My assignment today is to change a clients PHP 4 version to PHP 5.

I searched get_class i all the files and replaced them all with strtolower get_class and replaced the old files. Now if i replace general.inc it gives me the error but if i keep the old general.inc it works on php 4 atleast. So thats how i know the error is there. I tested the code on php 5 too but it gives me the same error and even more. For some reason its pointing to index.php but that works fine with the old general.inc.

I used exit; to find the line where it breaks. and that points to the line i gave you(the functions first line).
What that function is supposed to do is to check if the strText is longer than max allowed(for formating reasons).
This function i runned everytime i load the page.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP 4 -> 5 problem.

Post by Chris Corbyn »

What error? :banghead:

j/k :lol: Seriously though, we need to know the error.
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

check my posts. I already showed you the error. I edited both my posts i think.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: PHP 4 -> 5 problem.

Post by JAM »

Sorry, but I can't find the error you state you post either, just small lumps of code..

You have a problem with:

Code: Select all

foreach ($engSystem->arrStructure[INTERFACE_NAME][$engUser->fnGetParam("level")] AS $tmpKey => $tmpItem) {
...giving you...
Warning: Invalid argument supplied for foreach() in index.php on line 30
...but you also state that the problem lies within here...

Code: Select all

function BreakString($strText, $intMaxLength, $strSuffix = "") {
It's just not enough to assist with. For me.
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

Thats why i wanted to get someone on msn. I don't want to post alot of code on the internet when its not mine.
Disent
Forum Newbie
Posts: 7
Joined: Mon Jan 28, 2008 4:32 am

Re: PHP 4 -> 5 problem.

Post by Disent »

After i change the servers settings to run on PHP 5. I get this:


Warning: session_start() [function.session-start]: open(/var/tmp/sess_86c7d68856073d8a17c4ac47219fc5e4, O_RDWR) failed: Permission denied (13) in /htdocs/init/public.inc on line 5

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /htdocs/init/public.inc:5) in htdocs/init/public.inc on line 5

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /htdocs/init/public.inc:5) in /htdocs/init/public.inc on line 5

Warning: Cannot modify header information - headers already sent by (output started at /htdocs/init/public.inc:5) in /htdocs/init/public.inc on line 34
Internal Server Error
.......which says htacces file uses restricted directives and the PHP script takes too much resources... change the memory limit (memory_limit).

Not sure if i got this all right in english.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP 4 -> 5 problem.

Post by Christopher »

It looks like the webserver does not have permission to write to '/var/tmp/'. It may not exist or have the wrong permissions. Create it, change the permissions, or change it php.ini to '/tmp'.
(#10850)
Post Reply