script failing not sure why

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

SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

Post by SFADuncan »

So instead of:

Code: Select all

if (!session_is_registered("output"))
{
session_register("output");
}

$pwd = pathinfo(getcwd());
$directory = $pwdї'basename'];
$output = $directory;

I should do this?:

Code: Select all

if (!session_is_registered("output"))
{
$_SESSIONї'output'] = $output;
}

$pwd = pathinfo(getcwd());
$directory = $pwdї'basename'];
$output = $directory;
Or should this line:

Code: Select all

if (!session_is_registered("output"))
be changed too?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

if (empty($_SESSIONї'output'])) 
{ 
$_SESSIONї'output'] = $output; 
} 

$pwd = pathinfo(getcwd()); 
$directory = $pwdї'basename']; 
$output = $directory;
SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

Post by SFADuncan »

Yeah... my PHP book is a little out of date now... so, I've uploaded this and again, there appears to be an improvement... but I can still achieve this error, in spite of deleting all cookies of my system and starting again....

(BTW... I massively appreciate the advice and when I've solved this I'll be doing my penance by helping out in the less challenging HTML rooms!)

Simon
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i presume here you are trying to get the filename through $pwd['basename']

Code: Select all

$pwd = pathinfo(getcwd()); 
$directory = $pwdї'basename']; 
$output = $directory;
But will that ever work???

getcwd() only returns the current dir, not including the filename, so $output aint set to anything as far as i can see.

If it is the dir you want, that line should be

Code: Select all

$directory = $pwdї'dirname'];
SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

Post by SFADuncan »

The bit I want is the following after the URL... http://www.ealingcc.co.uk

so... I want one of the six directories isolated: home, about, cricket, etc

http://www.ealingcc.co.uk/[b]home[/b]/index.php

or

http://www.ealingcc.co.uk/[b]about[/b]/index.php

or

http://www.ealingcc.co.uk/[b]cricket[/b]/index.php

Simon
SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

Post by SFADuncan »

Substituting:

Code: Select all

$directory = $pwdї'dirname'];
for

Code: Select all

$directory = $pwdї'basename'];
...gives me permanent errors. The existing code must be working some of the time as I don't get the error on every click/link ?

Simon
Post Reply