Page 1 of 1

Stupid question about $_GET and include()

Posted: Wed Mar 03, 2004 5:59 pm
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

Posted: Wed Mar 03, 2004 6:09 pm
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.

Posted: Wed Mar 03, 2004 6:26 pm
by d3ad1ysp0rk
try echoing out a few debug things (ie. the $loc var)

Posted: Wed Mar 03, 2004 10:34 pm
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

Posted: Wed Mar 03, 2004 10:40 pm
by infolock
chmod doesn't exist in windows... u just don't have your paths correct in your files.