Page 1 of 1
Apache problems on windows
Posted: Thu Dec 08, 2005 11:48 pm
by paqman
hey I'm trying to set up Apache to run php files on my windows xp computer. It all went fine, I ran Apache and was able to open the php file in Internet Explorer. The only problem is the pages won't work right. The main page, index.php, works by
(links are index.php?page= )
It just won't include any files. It works fine on the internet, but won't on my computer. Is there something I haven't configured or something else I have to download? thanks!
Posted: Fri Dec 09, 2005 8:51 am
by timvw
You might want to search this forum for a "debugging 101".. If we don't have it, it would go like this:
Start with instructing php to report all errors and warnings:
Code: Select all
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
Next, test if $page contains what you want: (After a while you might want to switch to using a debugger)
Code: Select all
echo "page should contain: $page";
You will probably experience that the $page variable seems to be "gone". A search on the web (or this forum) will return many links to people that have experienced the same.
The solution is probably to use $_GET['page']. (Setting register_globals=on isn't a solution on the long term)
Posted: Sun Dec 11, 2005 10:42 pm
by paqman
I searched for other people with this problem but I couldn't find anything. Sorry, I'm completely new to having php and apache on my computer, where do I put those first 2 lines of code? Into the php command prompt? I tried displaying the variables like you said and nothing was there, like you said, and using GET did work. Is there any way to make the php less touchy (not needing all the extra code)?
Posted: Mon Dec 12, 2005 11:43 am
by Maugrim_The_Reaper
First of all when you include, PHP will read a file somewhere on the filesystem. Like all files you may need to spacify the entire path to that file.
So if you have all PHP file in C:\Apache\htdocs\, and all page files in \includes\ folder. You may need to use something like:
Code: Select all
//might be a good idea to strip slashes/periods this contains (a url injection could alter the path that's actually used
$page = $_GET['page'];
include_once('C:\Apache\htdocs\includes\' . $page);
You could always use require() rather than include(). include will not produce an error if it cannot locate your file, require() will create an error - and is therefore far more useful from a bug catching perspective...