Need help with codes

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
pweeapw
Forum Newbie
Posts: 4
Joined: Fri Mar 19, 2004 2:29 am

Need help with codes

Post by pweeapw »

Hi,

I'm a php as well as a forum newbie... I recently downloaded SPAW from Sourgeforge.net and am encountering problems with this part...

Code: Select all

if (!ereg('/$', $HTTP_SERVER_VARSї'DOCUMENT_ROOT']))
  $_root = $HTTP_SERVER_VARSї'DOCUMENT_ROOT'].'/';
else
  $_root = $HTTP_SERVER_VARSї'DOCUMENT_ROOT'];

It seems to work fine when i upload it to a server (running UNIX, Apache)... but when i try it on my local server, the DOCUMENT_ROOT fails to produce anything... I'm running WindowsXP with IIS5...

Thanx
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

the DOCUMENT_ROOT fails to produce anything
Not sure what you mean by that, but what does echo $_root; show after the code you pasted above?

(by the way, if the rest of the SPAW code is like that, i'd try to find something else to use, using an ereg for that is way over the top)
pweeapw
Forum Newbie
Posts: 4
Joined: Fri Mar 19, 2004 2:29 am

Post by pweeapw »

nothing...

but on the other server it produces the root structure e.g. /var/www/htm
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

ok, looking back at previous posts, it look like IIS doesn't set the DOCUMENT_ROOT variable, so you're going to have to set it yourself. So the code works on both servers you could do something like,
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$_SERVER['DOCUMENT_ROOT'] = 'whatever/the/docroot/is';
}
pweeapw
Forum Newbie
Posts: 4
Joined: Fri Mar 19, 2004 2:29 am

Post by pweeapw »

i see...

so i'll have to manually insert the root directory right?
if that's so then wouldn't it be easier to have it like this:

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'
{
$_root = 'whatever/the/docroot/is';
}

just asking to know the difference bewteen putting it into
$_SERVER["DOCUMENT_ROOT"] instead if putting it straight into the $_root variable

oh yeah... and what do you mean by way over the top?
is there any other rich text editor that you would recommend instead?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Sure, putting it straight into $_root works too. Using an ereg to check the last char of a string is over the to as it has to invoke the regular expression engine which is too expensive for something a simple as that. A substr($_SERVER['DOCUMENT_ROOT'], -1) will get you the last character. I've not used any rtf editors myself, but there's a few threads on this site that discuss the merits of them, try a search for 'htmlarea' as that's one that's discussed...i think ;)
pweeapw
Forum Newbie
Posts: 4
Joined: Fri Mar 19, 2004 2:29 am

Post by pweeapw »

i'll do just that...

and thanx for all the help...
Post Reply