Stupid question about $_GET and include()

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

Post Reply
jcmarko
Forum Newbie
Posts: 2
Joined: Wed Mar 03, 2004 5:59 pm

Stupid question about $_GET and include()

Post by jcmarko »

I hope this all makes sense as I type this!

In my code, I'm using an index page that is holding all the locations of the links (i.e. index.php?loc=whateverpage)

This is the part of the code for it:
if(isset($_GET["loc"]))
{
$loc = $_GET["loc"];
if($loc=="mainmenujjtokoly")
{
include("client_homes/jjtokoly/mainmenu.html");
}
}

All of this is in a password protected website using sessions and a backend DB, but what's happening is when the application that I wrote tries to go to that link, the browser just returns a blank page, like the include file is not there or I have a path wrong (the file is there and the path is correct).

I know the user is getting logged in properly because in the mySQL DB, I write the time/date they logged in into a field.

The correct page based on the user that is logging in is getting called from the login page in this code snippet:

if ($_SESSION['user'] == "jjtokoly")
{
header('Location: index.php?loc=mainmenu'.$token);
}

$token is their username that I am adding to the end of the link. I know it's getting set because it shows up in the address bar in the browser properly.

But why won't the page display properly? Am I really missing something stupidly simple here? If you need more information, please let me know. Thanks!

-Joe
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Use require_once instead of include and put an error_reporting(E_ALL); as the first line of index.php, Eg
<?php
error_reporting(E_ALL);

That should highlight the where the problem is.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

try echoing out a few debug things (ie. the $loc var)
jcmarko
Forum Newbie
Posts: 2
Joined: Wed Mar 03, 2004 5:59 pm

Post by jcmarko »

PHP Warning: main(client_homes/jjtokoly/mainmenu.html) [function.main]: failed to create stream: Permission denied in C:\Program Files\Ensim\Sitedata\my_markovich\Inetpub\wwwroot\index.php on line 129 PHP Fatal error: main() [function.main]: Failed opening required 'client_homes/jjtokoly/mainmenu.html' (include_path='.;c:\php4\pear') in C:\Program Files\Ensim\Sitedata\my_markovich\Inetpub\wwwroot\index.php on line 129

This is the error that gets returned. What I don't understand is that it works for one login, but not any of the rest!

Could this be stemming from the folder permissions. Should I do a chmod on them?

-J
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

chmod doesn't exist in windows... u just don't have your paths correct in your files.
Post Reply