 |
| View previous topic :: View next topic |
| Author |
Message |
Cavedog699 Newbie
Joined: 11 Oct 2005 Posts: 3
|
Posted: Oct 11th, 2005 10:51 PM Post subject: Drawing a blank |
|
|
I need help everytime i run this it gives me a blank screen. with just the title.
| Code: |
<?
include("/include/session.php");
?>
<html>
<head>
<title>Cavedog699.Com Pictures</title>
</head>
<body>
<? if($session->logged_in){
if($session->userlevel>=3) {
echo "$session->userlevel";
?>
<img src="/index_files/image001.gif" align="center">
<hr>
<div align="Left">
Links<br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
<a href="/phpbb2/"><img src="/needed/button3.jpg"></a><br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
<a href="/pictures.php"><img src="/needed/button6.jpg"></a><br>
</div>
<? }
elseif ($session->userlevel<=2){
echo 'You Do Not Have Permision To Acess This Area'; }
else {
header("Location: ../login.php");
} }
?>
</body>
</html>
|
|
|
| Back to top |
|
DoobieKeebler Moderator

Joined: 17 Jun 2005 Posts: 254 Location: 181°15'2.003"W, 93°5'16.956"N
|
Posted: Oct 12th, 2005 09:03 AM Post subject: |
|
|
Based on the path in your include statement I wonder if PHP is finding session.php. Just after your body tag, type this:
| Code: | <? if (! isset($session->logged_in) {
echo "Looks like PHP can't find session.php.";
}
?> |
If $session->logged_in isn't set then (to the best of my knowledge) PHP isn't finding session.php.
Unless you've got something set for default path, PHP treats the path as absolute (i.e. the *nix equivalent of C:\include\session.php). This is different than HTML which expects to find "include" as a subfolder of the root of your webspace. (I can explain that better if need be. Otherwise just know that PHP and HTML start looking in two different folders.)
You may have to change your include statement to:
| Code: | | include($_SERVER['DOCUMENT_ROOT']."/include/session.php"); |
Now PHP and HTML will look in the exact same folder for session.php. _________________ Always take into account what a user would never ever in a million years do, because someone will.
"In theory, there's no difference between theory and practice. In practice, there is." -- Yogi Berra |
|
| Back to top |
|
DoobieKeebler Moderator

Joined: 17 Jun 2005 Posts: 254 Location: 181°15'2.003"W, 93°5'16.956"N
|
Posted: Oct 12th, 2005 09:38 AM Post subject: |
|
|
Rereading my post, I'm going to go into the "two different paths" thing. Pull up a chair, grab a snack, and hold on. Or just skip this particular reply.
To make this a bit easier to visualize, I'll use Windows paths instead of *nix (short for Unix, Linux, FreeBSD, etc. and related OSes) paths.
It's a given that everything on a hard drive exists somewhere. Let's say that whoever set up the server wants all users' websites to go in C:\websites\customer\common\start. My website exists at C:\websites\customer\common\start\doobie.
On the server side there's more to a website than just HTML files and images. So the server admin creates a folder at C:\websites\customer\common\start\doobie\www. When I upload my main index.html file it gets uploaded to this folder. Using only HTML, I can't go "above" this folder (i.e. I can't get to C:\websites\customer\common\start\doobie). When I say img src="/logo.jpg" the server looks for C:\websites\customer\common\start\doobie\www\logo.jpg since the "highest" folder it has access to is doobie\www. Still with me?
Now, the way PHP works, it has access to the root of the server. So if I tell PHP that I want "\include\session.php" it's going to look for C:\include\session.php. I don't have server permission to put a file there. So even if there is a session.php file there it isn't mine. I have to tell PHP to start with the folder where my main index.html file would be. That location is stored in a variable called $_SERVER['DOCUMENT_ROOT'] (or $DOCUMENT_ROOT in PHP 4.2 or lower).
I believe this is the problem that Cavedog699 is running into. I think Cavedog699 is thinking that PHP is going to look for the file in the same place that HTML would, but as we've seen PHP is looking in a completely different place.
DISCLAIMERS:
1) Yeah, I know that technically it's wrong to say that HTML looks for anything. The server software (Apache most likely) is doing the actual looking. But it's a little easier to understand it this way.
2) I know you can specify default include paths for PHP to look in (and I've incorrectly mentioned that in my previous post) but on further reflection it wouldn't make sense to include everybody's document roots. It's a really really really bad idea to let my scripts call your scripts. I don't even want to think how quickly that server could be compromised. If I'm going to have a zombie on my hands it had better be because somebody thinks they're coasters. (A Zombie is an alcoholic drink.)
3) This post may cause drowsiness. Do not read this post and drive until you know how this post will affect you. _________________ Always take into account what a user would never ever in a million years do, because someone will.
"In theory, there's no difference between theory and practice. In practice, there is." -- Yogi Berra |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|