Reply
A tamplate script
Old 07-08-2004, 03:30 PM A template script
nat
nat's Avatar
Skilled Talker

Posts: 52
Location: Netherlands
I'm working on a basic template script for a friends web site.

this is what i've conjured so far (as an example of part of it);

PHP Code:
<?php

$page 
$_GET['page'];
$link "content/".$page."/title.txt";

if (!include(
$link)) { // line 9
include('$link');       // line 10
} else { 
include(
'content/home/title.txt');
}

?>
The problem is if $page (which receives it's value from the URL) is invalid or undeclared then I get 4 warnings about line 6 and 7 and the content of the 'else' isn't executed.
I don't know how to make the 'if' any more graceful. What can I do?

Last edited by nat : 07-09-2004 at 01:55 PM. Reason: typo
nat is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-08-2004, 03:38 PM
SN3
Novice Talker

Posts: 14
What are the errors?
SN3 is offline
Reply With Quote
View Public Profile
 
Old 07-08-2004, 05:44 PM
nat
nat's Avatar
Skilled Talker

Posts: 52
Location: Netherlands
Quote:
Originally Posted by SN3
What are the errors?
I fail to see the relevance...
nat is offline
Reply With Quote
View Public Profile
 
Old 07-08-2004, 10:09 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
errors have a lot of relevance. They can give you tons of info if you know how to read them properly. Besides that, why ask for help if the first time someone try's to help you ask them what the relevance of their question is? Maybe they know something you don't, isn't that the point of your asking?
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 01:49 PM
nat
nat's Avatar
Skilled Talker

Posts: 52
Location: Netherlands
ok, sorry.

the errors are as follows;

Code:
Warning: main(content//subnav.txt): failed to open stream: No such file or directory in /Users/nat/Sites/BS/vartest.php on line 9

Warning: main(): Failed opening 'content//subnav.txt' for inclusion (include_path='.:/usr/lib/php') in /Users/nat/Sites/BS/vartest.php on line 9

Warning: main($link): failed to open stream: No such file or directory in /Users/nat/Sites/BS/vartest.php on line 10

Warning: main(): Failed opening '$link' for inclusion (include_path='.:/usr/lib/php') in /Users/nat/Sites/BS/vartest.php on line 10
I think i must have miss-read your reply the first time, thought u said "what are errors"
nat is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 02:38 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
On line ten take out single quotes or the ' surrounding the variable. Single quotes make it litteral so its looking for $link instead of the value of the link.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 03:13 PM
nat
nat's Avatar
Skilled Talker

Posts: 52
Location: Netherlands
Thanks that helped :-)

I also managed to solve the other problem. After a bit of more research and tinkering I found

if (is_readable($link))

works much better for me than

if (!include($link))

All better
nat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to A tamplate script
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13367 seconds with 12 queries