Koozali.org: home of the SME Server

PHP Problem?

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« on: March 17, 2007, 06:28:21 PM »
I've been using SME since version 5.5 to host a couple of small websites.  I then upgraded to version 6, and am now running version 7.1.2

My problem is that some PHP scripts which we were using for a simple bulletin board no longer work under version 7.  They are simple scripts, in an i-bay, with PHP etc. enabled for that i-bay.

I have reinstalled an old pc with version 6.0 (straignt from CD - no updates - and created the i-bay, transferred everything to this machine, and everything works perfectly.

Although I've used SME for several years now, my 'behind the scenes' knowledge is very small.  The beauty of SME for me is that everything just works like you want it to - I've never needed to know too much.

My question is - if these scripts worked with earlier versions (5.5 & 6), why don't they work in 7?  Is it a PHP problem or a SME problem?

I have looked all day on the forum and I can't find anything.  Hopefully I'm posting this in the right place.

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Problem?
« Reply #1 on: March 17, 2007, 10:41:29 PM »
Well the first thing i would do is to check what version of php runs on sme 6 and what on sme 7.
"It should just work" if it doesn't report it. Thanks!

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #2 on: March 17, 2007, 10:58:03 PM »
Thanks for your reply.

How do I do this?

How will this help me?

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Problem?
« Reply #3 on: March 17, 2007, 11:34:58 PM »
Well this should give you some info about php changes (what php developers changed in their code).
Some commands don't work on your script so this should at least let you know why. Let's say that the devs decided to shorten codes in the newer versions.

You would check and then search for changes on their webpage.

Well i go to software installer in server manager pannel and then click on remove and check for php version there (i know that there is a way to do this trough shh but this is the fastest way for me).

So i would do that in both versions and then go to http://www.php.net/ChangeLog-4.php and check for changes that were made and could mess with my script.
"It should just work" if it doesn't report it. Thanks!

Offline william_syd

  • *****
  • 1,608
  • +0/-0
  • Nothing to see here.
    • http://www.magicwilly.info
Re: PHP Problem?
« Reply #4 on: March 18, 2007, 12:06:20 AM »
Quote from: "dave simmons"


My problem is that some PHP scripts which we were using for a simple bulletin board no longer work under version 7.  They are simple scripts, in an i-bay, with PHP etc. enabled for that i-bay.



What errors are you getting ?
Regards,
William

IF I give advise.. It's only if it was me....

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #5 on: March 18, 2007, 12:21:22 AM »
I'm not getting any error messages - just a blank (white) screen.  This is on a screen where people can post messages to a bulletin board.

When they fill in all (3) fields and click on 'post' the screen goes white and nothing else happens.  Their message doesn't get posted.  WHat should happen is that their message gets written away to a text file (it's not a big site!) and they get a screen saying 'thank you'.

It works fine on SME 6.0 - it's only on version 7 that it won't work.

Hope this helps.  Thank you for your reply.

Offline william_syd

  • *****
  • 1,608
  • +0/-0
  • Nothing to see here.
    • http://www.magicwilly.info
PHP Problem?
« Reply #6 on: March 18, 2007, 12:34:05 AM »
Try enabling php errors.

This post will show how...
http://forums.contribs.org/index.php?topic=35635.msg156439#msg156439
Regards,
William

IF I give advise.. It's only if it was me....

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #7 on: April 01, 2007, 06:38:13 PM »
Okay, sorry for the long delay.  I've now made the changes you suggested, and here is the result:

Parse error: parse error, unexpected '}' in /home/e-smith/files/ibays/wpsa/html/gastenboek/guestbook.php on line 222

What does this mean?

Please note - nothing has changed in the php files, only upgraded to version 7 of the system.

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #8 on: April 01, 2007, 06:58:40 PM »
PS  Have removed the offending bracket in line 222.  I don't now get the error message, the program continues to show the bulletin board - as it should - but the new message isn't added.  It adds a blank message - the text and the name of the person posting aren't shown.  The messages should be written away to a simple text file (it's not a big bulletin board), but the text file is unchanged.  

I repeat, everything works perfectly on all earlier versions of the server (5 & 6).  Its only on version 7 that it won't work.  It's a shame because all the other improvements (especially spam filtering) are brilliant.

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
PHP Problem?
« Reply #9 on: April 01, 2007, 07:39:52 PM »
Add the bracket again, because with the bracket your script run ok.
Then:
Code: [Select]
db accounts setprop <ibayname> PHPBaseDir /home/e-smith/files/ibays/<ibayname>/:/tmp
signal-event ibay-modify <ibayname>


Ofcourse <ibayname> is the name of the ibay you have used for your script.

Also, make sure you have the correct permission in the folder of your script. Review the install instruction of the script. When you migrate maybe the permission are not the same.
The best method for my when migrate from one server to other is compressing the old and expanding in the new server. This method hold the same permission. To acomplish this, in the old server, under the root instalation of your script, open midnigh commander (mc). Then push F2 and choose compress tar.gz.
The copy this file to the new server, decompress and all the permissions are the same.

Other issue is the use of .htaccess. If the script use .htaccess file for some function you need to enable in the ibay.

Code: [Select]
db accounts setprop <ibayname> AllowOverride All
signal-event ibay-modify <ibayname>

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #10 on: April 01, 2007, 07:49:23 PM »
Hi Normando,

Thanks for your answer.

The scripts didn't run fine with the bracket in place  All we got was a white screen.  Then, by activating the PHP errors (as detailed in another post), we got the error message 'Parse error: parse error, unexpected '}' in /home/e-smith/files/ibays/wpsa/html/gastenboek/guestbook.php on line 222'.

Removing the bracket allowed the php program to run further, it just didn't add anything to the bulletin board or the file where the messages are stored.

In answer to your advice about how to migrate, I carried out a backup of the old server using the backup feature in server-manager, and the used the restore function on the newly-installed version 7 server (same machine).

The web site worked perfectly on earlier versions of the server, and we haven't changed anything, only the server version.

Thanks again for your post, any further advice would be very much appreciated.  If I haven't given enough (or the right) information please ask.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP Problem?
« Reply #11 on: April 01, 2007, 09:08:24 PM »
First of all provide version numbers of the php version you are/were using. you can do this by issuing the php -v command on the server shell. This way we know what we are talking about and can determine what changes are causes by the different versions of php and what is caused by the system.

I find it hard that no changes to the code where made and that the parser now complains about a bracket, this is no normal behavior, are you sure you did not change anything? Do you have the original source to try and compare/reinstall?

Could it be that register_globals was on on the old server and is not on the newer version? It could also be that your scripts are not compatible with the newer global variables, somewhere (I don't know the version number, I believe 4.3) PHP changed serveral globals like $HTTP_POST_VAR to $_POST, this holds not only for $_POST but for a handfull others as well.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #12 on: April 01, 2007, 09:38:47 PM »
Hi Cactus,

Thanks for your reply.  I am 100% sure that we didn't change anything in the PHP scripts.  All we did was back up the old server and restore to the new (using the backup/restore function in server-manager).

The PHP version on the new machine is 4.3.9  I don't know what it was on the old machine (I only have the one machine, so I have overwritten the old install).   When I first identified the problem I did a reinstall of SME 6 on the machine and restored my backup to that.  Then everything worked fine, so it really is something which has changed from the one system to the other.  I don't really want to reinstall SME6 again to identify which version of PHP was installed.  It was whatever shipped with version 6 of SME.

Basically we went from an standard installed SME 6 to an standard installed SME.

What is register_globals?  Sorry - I am a complete novice.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP Problem?
« Reply #13 on: April 01, 2007, 10:15:59 PM »
Quote from: "dave simmons"
What is register_globals?  Sorry - I am a complete novice.
Register globals means that some variables are known all throughout the environment (the php environment in this case), they are registered as global, and can be accessed from every where in the source code. More information can be found on the php website: http://www.php.net/register_globals  (I noticed that his was changed in PHP version 4.2).

Unfortunately I do not know the sourcecode, so I can not help you to much at the moment. Is it code from a well-known program or has it been written for/by you? Perhaps you can provide (a fragment) of the code so we/I can perhaps help you debug the problem.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Rob65

PHP Problem?
« Reply #14 on: April 07, 2007, 07:33:34 PM »
Dave,

are you passing variables through your URL (e.g. page.php?id=2). If that is true you are depending on the register_globals setting.

You need to set "register_globals = On" in the /etc/php.ini file. Beware: this file can begenerated from the SME templates, so this setting should be copied in the template (/etc/e-smith/templates/etc/php.ini/40DataHandling) .

Other settings that may be interesting to change:

$allowOverride = "all";
$followSymLinks = "enabled";

in etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess40ibays

This allows the use of the .htaccess file (able to override all default settings) and the use of symbolic links (as used by e.g. typo3)

I just did this two days ago and happened to have my notes still on my PC.

Good luck!

Rob