Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 03:16:28 AM

Pages: [1]   Go Down
  Print  
Author Topic: Proper PHP configuration  (Read 2642 times)
Vladimir Nozdryn
Newbie
*
Offline Offline

Posts: 4


WWW
« on: April 16, 2010, 04:22:13 AM »

Hello,
I am having issues with PHP scripts on many HTML pages.
For example standard PHP variables do not work:
This line:
require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
had to be replaced by this line:
require_once('/home/account/public_html/'._SAPE_USER.'/sape.php');
This is how .htaccess currently looks like:
-----------------------------------------
DirectoryIndex index.htm index.php
ErrorDocument 404 /404.html
AddType x-httpd-php .php .htm .html
suPHP_ConfigPath /home/account/public_html
-----------------------------------------
Also for some reason scripts work when this page is called by its public URL:
http://www.interlit2001.com/counter.htm
but do not work when it is accessed as:
http://stigma.lunariffic.com/account/counter.htm
and:
http://www.interlit2001.com/contact-1.htm
http://www.interlit2001.com/contact-1a.htm
http://www.interlit2001.com/contact-1b.htm

Please help with proper PHP configuration!!!
Thank you!
« Last Edit: April 20, 2010, 01:28:51 AM by Vladimir Nozdryn » Logged

Welcome to My Site:
http://www.interlit2001.com
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5212



« Reply #1 on: April 16, 2010, 06:08:42 AM »

When you say that $_SERVER['DOCUMENT_ROOT'] "doesn't work", what kind of error do you get? That $_SERVER doesn't exist, or that the DOCUMENT_ROOT element doesn't exist, or it exists but has a bogus value, or...? According to http://us.php.net/manual/en/reserved.variables.server.php it may or may not already include a trailing /.

Have you checked what level of PHP you're actually running with?
Code:
<?php phpinfo(); ?>
will tell you. I'd check to be sure you're not forcing your system to use some way backlevel PHP 3 or something. You want to be thinking about going to PHP 5 anyway, as PHP 4 is out of support. You have PHP scripts disguised as HTML? If nothing else works, you might consider URL rewriting to change .htm to .php on the fly (rename the files to .php).

The operating environment and PHP evidently are slightly different when you run under http://SERVER/~ACCOUNT rather than http://YOURDOMAIN. In some cases, PHP might even be disabled. You could talk to support to find out whether PHP is available, or just test it yourself with the phpinfo script. It's possible that your .htaccess is not run, or is handled differently, or the PHP defaults are different, under http://SERVER/~ACCOUNT.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Vladimir Nozdryn
Newbie
*
Offline Offline

Posts: 4


WWW
« Reply #2 on: April 16, 2010, 10:51:03 AM »

Hello,
Thank you for your reply.
I’ll specialize the question.
At page http://www.interlit2001.com/contact-1.htm there are two scripts:

<?php
 define('_SAPE_USER', 'e4e81a2de78ebc730e6903a8823e97ca');
 require_once('/home/account/public_html/'._SAPE_USER.'/sape.php');
 require_once('/home/account/public_html/'._SAPE_USER.'/linklink.php');

 $sape = new SAPE_client();
 $linklink = new LinkLink_client();
 echo $sape->return_links(3).' ';
 echo $linklink->return_links(3);
?>

And

<?php
 echo $sape->return_links().' ';
 echo $linklink->return_links();
?>

All displayed OK with non standard lines (red).

At page http://www.interlit2001.com/contact-1b.htm there are two scripts:

<?php
 define('_SAPE_USER', 'e4e81a2de78ebc730e6903a8823e97ca');
 require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
 require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/linklink.php');

 $sape = new SAPE_client();
 $linklink = new LinkLink_client();
 echo $sape->return_links(3).' ';
 echo $linklink->return_links(3);
?>
and
<?php
 echo $sape->return_links().' ';
 echo $linklink->return_links();
?>

With standard lines (red) non displayed links in blue rectangle.

At page http://www.interlit2001.com/contact-1a.htm there is one script:

<?php
 echo $sape->return_links().' ';
 echo $linklink->return_links();
?>

All bottom of page non displayed.

This is how .htaccess currently looks like:
-----------------------------------------
DirectoryIndex index.htm index.php
ErrorDocument 404 /404.html
AddType x-httpd-php .php .htm .html

CHMOD on folder and executable scripts is 755.
Forum vBulletin 3.6.2 (PHP4) and other scripts had worked normally.

Note:
These scripts at the previous hosting had worked normally with standard lines.


« Last Edit: April 20, 2010, 01:31:06 AM by Vladimir Nozdryn » Logged

Welcome to My Site:
http://www.interlit2001.com
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5212



« Reply #3 on: April 16, 2010, 01:12:42 PM »

If at some point in that code, you
Code:
echo $_SERVER['DOCUMENT_ROOT'];
what is printed?

Are you on an Apache server, rather than IIS (where DOCUMENT_ROOT apparently isn't available)? If your .htaccess is working, presumably it is Apache.

As for the DOMAIN vs SERVER/~ACCOUNT, can you say where it's breaking? Does PHP run at all? Can you run phpinfo and see that PHP is OK? "Does not work" is a bit vague.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Vladimir Nozdryn
Newbie
*
Offline Offline

Posts: 4


WWW
« Reply #4 on: April 17, 2010, 03:41:41 AM »

Hello,
> If at some point in that code, you
Code:
echo $_SERVER['DOCUMENT_ROOT'];
what is printed?

If this line (red) is added in script:
<?php
 define('_SAPE_USER', 'e4e81a2de78ebc730e6903a8823e97ca');
 require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
 require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/linklink.php');
 $sape = new SAPE_client();
 $linklink = new LinkLink_client();
 echo $sape->return_links(3).' ';
 echo $linklink->return_links(3);
echo $_SERVER['DOCUMENT_ROOT'];
?>

In blue rectangle is printed:
/home/account/public_html
See http://www.interlit2001.com/contact-1c.htm

> Are you on an Apache server
Yes:
Apache Version 2.2.3
PHP Version 5.2.9

> "Does not work" is a bit vague.
At page
http://www.interlit2001.com/club.htm
in blue rectangle (bottom of Page) links are displayed.

And at page
http://stigma.lunariffic.com/account/club.htm
in blue rectangle (bottom of Page):
return_links(3).' '; echo $linklink->return_links(3); ?> return_links().' '; echo $linklink->return_links(); ?>
is displayed.

> Does PHP run at all?
Forum vBulletin 3.6.2 (PHP4) and other scripts had worked normally.

Thank you!
« Last Edit: April 20, 2010, 05:22:38 AM by Vladimir Nozdryn » Logged

Welcome to My Site:
http://www.interlit2001.com
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5212



« Reply #5 on: April 17, 2010, 07:27:27 PM »

> If at some point in that code, you
OK, if echo... returns /home/ACCOUNT/public_html, it's impossible that the two "require_once" calls aren't working exactly the same way as if you hardcoded /home/ACCOUNT/public_html into them. You should have gotten an error if the required files couldn't be found, and $sape and $linklink would fail because the SAPE_client  and LinkLink_client classes weren't found, and $sape-> and $linklink-> would have given error messages about a bad method. So, the problem must be in the methods themselves returning an empty string or just some HTML comments. The use of $_SERVER versus hardcoding the path can't make any difference -- what else changed at the same time?

Quote
return_links(3).' '; echo $linklink->return_links(3); ?> return_links().' '; echo $linklink->return_links(); ?>
That looks like PHP isn't running, or this code is after ?> and before <?php. Does the rest of the PHP code appear to be running? Also notice that you have ?> marking the end of a PHP section and then more PHP code and then another section-ending ?>. You've got real problems there with the code structure.

Are you changing more than one thing at once? You must change just one thing at a time, or you'll never figure out what's causing what (use $SERVER instead of the hardcoded path, OR use SERVER/~ACCOUNT instead of DOMAIN).

I ran one of your pages through the W3C validator, and it was very unhappy (hundreds of errors). If you're using a template, it may be difficult to clean it up, but you should at least be aware of what problems there are. I saw HTML like </tr></tr> on one of the pages, which isn't legal and indicates major problems with the program structure.
« Last Edit: April 22, 2010, 12:15:02 PM by MrPhil » Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Vladimir Nozdryn
Newbie
*
Offline Offline

Posts: 4


WWW
« Reply #6 on: April 22, 2010, 07:39:53 AM »

Hello, MrPhil!
Thanks a lot, you’ve helped me very much!
LunarPages is our fourth hosting, and nowhere had I received such effective help.
Issue 1.
You have been right, the cause of errors was in PHP scripts, after their modification everything began working normally, even with standard PHP variables $_SERVER['DOCUMENT_ROOT'].
I have already made all the necessary corrections at the server.
Issue 2.
Nothing has changed as yet, but as it doesn’t affect the site activity in public access, let it temporarily stay as it is.
______________________________
I do know about the errors in code of Pages, but 90-95% of them belong to Java scripts of various counters, ratings and so on, changing which is not allowed.

Thank you!

Vladimir Nozdryn

P. S. Please replace in your messages OK, if echo... returns /home/… and …hardcoded /home/… by /home/account/public_html.  I have already done that.
« Last Edit: April 23, 2010, 07:04:21 AM by Vladimir Nozdryn » Logged

Welcome to My Site:
http://www.interlit2001.com
Pages: [1]   Go Up
  Print  
 
Jump to: