[Help] php codes can't be rendered well.

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
river001
Forum Newbie
Posts: 10
Joined: Thu Mar 11, 2004 6:14 pm
Location: Ontario, Canada

[Help] php codes can't be rendered well.

Post by river001 »

I am using linux+apache+php+mysql solution now(I've never used it before).

the problems are:

(1) If I use <?php .......?> style, it works.
But if I use <? ...... ?>, apache cannot interpret the codes, and only render all the codes directly into my browser.

(2) I've set the value of DocumentRoot in httpd.conf, but when I use the following codes to display the value of $DOCUMENTROOT, I can see nothing:

<?php print $DOCUMENTROOT; ?>

so the following codes don't work either:
<?php include ($DOCUMENTROOT."/files/header.inc"); ?>

I've tried a long time, anyone who can help me, I will appreciate it very much.

Thanks a million!
river001
Forum Newbie
Posts: 10
Joined: Thu Mar 11, 2004 6:14 pm
Location: Ontario, Canada

Re: [Help] php codes can't be rendered well.

Post by river001 »

toweter wrote: the name of the variable is 'DOCUMENT_ROOT',
if it not works try it with "$_SERVER['DOCUMENT_ROOT']"
Thank you so much!

The problem is I cannot change the codes, because the codes are already done by others, I am deploying the whole website.

Do you have some other way to make $DOCUMENTROOT work?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

are you saying you can't edit the script and/or the php.ini file??
river001
Forum Newbie
Posts: 10
Joined: Thu Mar 11, 2004 6:14 pm
Location: Ontario, Canada

Post by river001 »

Illusionist wrote:are you saying you can't edit the script and/or the php.ini file??
I cannot edit the script but I can edit php.ini.
Thanks, I'll turn on the "register_globals" to make $DOCUMENT_ROOT work.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

but if you can't edit the script, which i dont see why you can't, the script wont work anyways. Your variable isn't $DOCUMENT_ROOT, which it should be, its $DOCUMENTROOT and that wont work, at least i highly doubt that it will. And if the script is on your server then why can't u edit it??
river001
Forum Newbie
Posts: 10
Joined: Thu Mar 11, 2004 6:14 pm
Location: Ontario, Canada

Post by river001 »

Illusionist wrote:And if the script is on your server then why can't u edit it??
Because I'm not allowed to edit the codes. The whole website is working on a server, now I want to deploy it on the other server.

I've solved the problem by following your way, thank you so much!
Post Reply