Forum Moderators: coopster

Message Too Old, No Replies

error when viewing the page on localhost

i'm new to php!

         

sebbothebutcher

7:50 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



hi i'm new to php, so this bit of code might look too easy to some php gurus...
i'm trying to write a .php file that displays a different output, depending on the "id" variable (e.g. index.php?id=01) it looks like this:

<?php
switch $_GET["id"]
{
case "00":
include('00/index.php');
break;
case "01":
include('01/index.php');
break;
case "02":
include('02/index.php');
break;
default:
include('error.php');
}
?>

#### HTML CODE ####

anyway, if i type localhost/php/index.php the browser generates an error message looking like this:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

i am using win2k (iss 5) and i've installed php... can anybody help me?

XMLMania

8:30 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



<?php
switch ($_GET['id']) {
case "00":
include('00/index.php');
break;
case "01":
include('01/index.php');
break;
case "02":
include('02/index.php');
break;
default:
include('error.php');
}
?>

Does this work? Note the brackets () around $_GET['id']

sebbothebutcher

9:02 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



well... actually i don't think that something is wrong with the code, but i messed something up elsewhere...
it happens with ANY .php file... even with a completly empty one...
any suggestions?

ergophobe

9:11 pm on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No suggestions yet, just questions:

- what server + OS are you using?

- has php ever worked on that server?

If Apache, have you modified your httpd.conf file to add php?

sebbothebutcher

9:23 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



well... it's my local computer.
1. OS: win2k

i'm trying it with
2. ISS 5(Internet Information Services)

3. never...

i have a place to upload it, and it works there, but i want to have it working it on my local pc in order to check wether the .php works... uploading every time is too complicated!

chaplin

10:43 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



I will highly recommend you to download Apache and PHP versions for windows from their official sites.
Running PHP on IIS can be a big pain. In your case, PHP is not configured at all.

If you need help with apache and php, more people will be able to help you here :)

sebbothebutcher

5:13 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



okay... i've installed apache now, and i've downloaded + installed php but i think i still need to configure something, because php files are viewed as if they were a text file!

jatar_k

6:02 pm on Apr 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Take a look at these
PHP Runtime Configuration [ca.php.net]
Details of installing PHP with Apache [ca.php.net]

XMLMania

6:03 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



Instructions:

Open your httpd.conf file.
(in Apache/conf/).

Search for: "LoadModule ", when you get to the list add the location of the PHP Apache SAPI (this will most likely be different for you):

LoadModule php4_module "E:\PHP\sapi\php4apache2.dll"

(note this is for Apache 2).

Now search for "AddType application", when you get to the list add:

AddType application/x-httpd-php .php

Save the *.conf file and restart Apache. It *should* now work!

sebbothebutcher

6:37 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



hm... i've added

LoadModule php4_module "C:\PHP\sapi\php4apache.dll"

because i'm using Apache 1.3.x actually... but when i start apache it says:

syntax error on line 194 of c:/programme/apache/conf/httpd.conf:
cannot load c:/php/sapi/php4apache.dll into server: (126) Das angegebene Modul wurde nicht gefunden
(in english: the specified module was not found)

the file c:/php/sapi/php4apache.dll DOES exist, so i don't know why apache says that it doesn't...

jamie

7:07 pm on Apr 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi sebbo,

just a thought, have you tried a complete set like foxserv.net - it is a '1-click' installer which installs php, mysql and apache on windows. might be easier that way?

edited for typo

sebbothebutcher

7:17 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



well... acutally all the installations all were 1 click installers, but seperate ones... is there a good one that contains apache, mysql and php?

sebbothebutcher

8:51 pm on Apr 20, 2004 (gmt 0)

10+ Year Member



i just downloaded Foxserv and everything works fine... thanks for your help!