![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Member
Join Date: Jun 2001
Location: Redlands Shire, Brisbane, QLD
Posts: 812
|
Hola!
I need help with some PHP coding. I need to see if this is correct. Because it doesn't seem to be correct to me. I have this in a sep script. Known as bs.php PHP Code:
What's the problem is. That I'm trying to set a 404 error page. Like this page: http://www.xis.com.au/~dicey/bs.php?page=drinking But... When Someone clicks on a link that works. For Example: http://www.xis.com.au/~dicey/bs.php?page=about Somehow something is inlcuding the error404.php into any page that works! It's pissing me off! Please tell me what to do! Thank you.
__________________
Generalization is all evil. Total Overdose!!! Drink or Die!!! XX- Who has done deals over the OCAU Forum trading area please contact me to put your name on the sig. |
|
|
|
| Join OCAU to remove this ad! |
|
|
#2 |
|
<blank>
Join Date: Jun 2001
Location: Perth, WA
Posts: 5,345
|
I know SFA about PHP, but do have experience with a number of other server-side scripting languages....so I'll have a go...
I don't believe you can do conditional includes. Instead, always @include error404.php on every page. In error404.php, have a function which will generate the HTML for the 404 error, and call this function when you want to display the 404 error. Cheers, Martin. |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2001
Location: Gold Coast, QLD
Posts: 828
|
You reckon this would work?
Code:
<?php
if*($page=='about')*include('about.php');
if*($page=='photoalbum')*include('album.php');
if*($page=='links')*include('links.php');
if*($page=='about-brandon')*include('brandon.php');
else {
if*(file_exists($show)){
@include("$show");
}else{
@include("error404.php");
}
}
?>
|
|
|
|
|
|
#4 |
|
Never a frown..
Join Date: Jun 2001
Location: Sydney
Posts: 4,401
|
at the very bottom of your about page put a HALT command in there, so it halts all other PHP related commands after it.
Other than that, im not sure. kinda half asleep atm :P |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2001
Location: Silicon Valley
Posts: 7,281
|
PHP Code:
exit; or like exit(1); or something I presume $show is already set to something?
__________________
There's a story about a golfer who sinks a 30-meter putt and someone says: 'Gee, that was lucky' and the golfer says, 'Yes, amazing how lucky you get when you practice 8 hours a day for 20 years'. |
|
|
|
|
|
#6 |
|
Member
Join Date: Aug 2001
Location: Sydney
Posts: 1,152
|
I don't know PHP either but the conditional logic in Bangers post and the original is not the same. That is if the if, else if and else statements have the same meaning as they do in Java, i'd be surprise if they didn't
Here is my guess PHP Code:
__________________
Don't use a big word where a diminutive one will suffice. Traders List.... (circa September 2003) |
|
|
|
|
|
#7 | |
|
Member
Join Date: Jun 2001
Location: Gold Coast, QLD
Posts: 828
|
Quote:
|
|
|
|
|
|
|
#8 | |
|
Member
Join Date: Jun 2001
Location: Adelaide
Posts: 4,636
|
Quote:
if*(file_exists($show)) It wont find the file because its not named right... should be: if*(file_exists("$show.php")) ? But the if.. else or using a big switch/case statement would be the best way.
__________________
MWP PC Database AdminCrystalfontz CrystalControl2 Author - Offical Forums Motoring Worklog - Toyota V8 RA28 Celica SA Classic Celica Club Member - Website |
|
|
|
|
|
|
#9 | |
|
Member
Join Date: Dec 2001
Location: Silicon Valley
Posts: 7,281
|
Quote:
I just released, hes got $page and $show to be 2 different variables when they basically do the same thing.
__________________
There's a story about a golfer who sinks a 30-meter putt and someone says: 'Gee, that was lucky' and the golfer says, 'Yes, amazing how lucky you get when you practice 8 hours a day for 20 years'. |
|
|
|
|
|
|
#10 |
|
Member
Join Date: Jun 2001
Location: Gold Coast, QLD
Posts: 828
|
Actually, this would do the job.
PHP Code:
This does work, I just tried it out. So if he wants to include the about.php file, then the URL is just bs.php?page=about
|
|
|
|
|
|
#11 |
|
Member
Join Date: Jun 2001
Location: Redlands Shire, Brisbane, QLD
Posts: 812
|
What I am trying to say is that I want the working pages NOT to inlcude the error404.php into any of the pages.
I want something like if a page exists. Do NOT include the error404.php If a page that does NOT exist. I want the error404.php to come up in action to let the surfers know that there is a 404. Please let me know. Thank you
__________________
Generalization is all evil. Total Overdose!!! Drink or Die!!! XX- Who has done deals over the OCAU Forum trading area please contact me to put your name on the sig. |
|
|
|
|
|
#12 |
|
Member
Join Date: Jun 2001
Location: Gold Coast, QLD
Posts: 828
|
Yeah dicey that's what the code I used above does, ie.
This link is to an about page I quickly made that does exist: http://members.lycos.co.uk/deanx0r/test.php?page=about The about information shown is stored in 'about.php'.... Whereas if you were to go to something that doesn't exist like: http://members.lycos.co.uk/deanx0r/t...ge=dflkgdfglkg you'll be presented with my lame 404 page.... |
|
|
|
|
|
#13 |
|
Member
Join Date: Jan 2002
Location: Sydney
Posts: 1,112
|
Took me all of about 30 secs to spot the problem. You havent defined $show. If you still havent figured it out, let me know.
__________________
Chazza |
|
|
|
|
|
#14 |
|
Member
Join Date: Jun 2001
Location: Redlands Shire, Brisbane, QLD
Posts: 812
|
Lame question....
Where do I put that in? Do I need to modify it so I can add more links to it?
__________________
Generalization is all evil. Total Overdose!!! Drink or Die!!! XX- Who has done deals over the OCAU Forum trading area please contact me to put your name on the sig. |
|
|
|
|
|
#15 | |
|
Member
Join Date: Dec 2001
Location: Silicon Valley
Posts: 7,281
|
Quote:
__________________
There's a story about a golfer who sinks a 30-meter putt and someone says: 'Gee, that was lucky' and the golfer says, 'Yes, amazing how lucky you get when you practice 8 hours a day for 20 years'. |
|
|
|
|
![]() |
| Bookmarks |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|