Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-09-2002, 10:37 PM   #1 (permalink)
basementman
Registered User
 
Join Date: Oct 2002
Posts: 3
basementman is on a distinguished road
Im a newb

yo i just started php today and i wanna be able to include files using GET but im doing something wrong and i cant figure out how to fix it.
I have a file called index.php
and somewhere in there the code is
PHP Code:
<a href=index.php?body=news.htm>Test</a>
<? include("$body");?>
when i click test it loads it fine but just index.php is giving me this error
Warning: Failed opening '' for inclusion (include_path='.:/usr/local/lib/php') in /usr/local/psa/home/vhosts/basementman.ppnhost.ws/httpdocs/new/index.php on line 65

how do i fix it so that it loads the news with the index and im able to have links that use GET, but dont show the news?

( take a look at http://basementman.ppnhost.ws/new/ )
basementman is offline   Reply With Quote
Old 10-10-2002, 01:03 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
Perhaps by:
PHP Code:
<a href=.....>
<?php
if(!isset($body) || "$body" == "")
 
$body='some_exisitng_default_file';
include(
"$body");
?>
Since the $body isn't declared, when you call the page first, without any ?body=blah
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 10-10-2002, 11:38 AM   #3 (permalink)
basementman
Registered User
 
Join Date: Oct 2002
Posts: 3
basementman is on a distinguished road
thx man
basementman is offline   Reply With Quote
Old 10-15-2002, 07:10 PM   #4 (permalink)
basementman
Registered User
 
Join Date: Oct 2002
Posts: 3
basementman is on a distinguished road
how would i set a default page for
PHP Code:
<?php

$thefile 
"data/$page.txt";
if (
file_exists($thefile))
{
include(
"$thefile");
}
else
{
include(
"data/error.txt");
}

?>
basementman is offline   Reply With Quote
Old 10-15-2002, 11:43 PM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
What do you mean with "default page" ??

If I'm catching what you want, you can do it something like:
PHP Code:
<?php
if (isset($the_file) && file_exists("data/$thefile.txt"))
{
include(
"/data/$thefile.txt");
}
else
{
  if(isset(
$the_file))
    include(
"data/error.txt");
  else
    include(
"data/default.txt");
}
?>
This allows the user to parse a ?the_file=something along in the url, and you will include that, if it exists. If it dosn't exists they will get an error, if they are just viewing the page, without any parsing of the the_file argument, they will be shown the default file.

Is it something like that you wanted ?
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm having some problems with inheritance... <-- newb mik0rs Standard C, C++ 5 04-08-2003 10:54 PM
I am a newb, how do you set multiple parts of an image as a link? I sniper baby HTML, XML, Javascript, AJAX 5 02-10-2003 06:40 PM


All times are GMT -8. The time now is 07:19 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting