p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: When testing my PHP script, the browser asks to save the file


Message #1 by "Francois Desautels" <fdesautels@r...> on Wed, 9 Oct 2002 17:42:22
Hi,

I've recently installed PHP4 on apache 1.3.20, I have a very basic 
test.php script.

<html>
<body>
<? echo "hello world" ?>
</body>
</html>

but eache time I go to localhost/test.php, the browser keeps on asking me 
to save to disk?  If I open the file that is saved, I see my exact script, 
I don't really know what I'm doing wrong.

Message #2 by Jefferis Peterson <jefferis@p...> on Wed, 09 Oct 2002 12:37:39 -0400
On 10/9/02 5:42 PM, "Francois Desautels" <fdesautels@r...> wrote:

> 
> but eache time I go to localhost/test.php, the browser keeps on asking me
> to save to disk?  If I open the file that is saved, I see my exact script,
> I don't really know what I'm doing wrong.

Php is not active. What system and what OS?

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #3 by "Francois Desautels" <fdesautels@r...> on Wed, 9 Oct 2002 18:09:30
I'm runnign mandrake 8.2, on an Athalon.  I went through the httpd.conf 
file, uncommenting the following, and adding index.php to the mod_dir.c 
section.

#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps


<IfModule mod_dir.c>
    DirectoryIndex index.php index.htm index.html
</IfModule> 



> On 10/9/02 5:42 PM, "Francois Desautels" <fdesautels@r...> wrote:

> 
> but eache time I go to localhost/test.php, the browser keeps on asking me
> to save to disk?  If I open the file that is saved, I see my exact 
script,
> I don't really know what I'm doing wrong.

Php is not active. What system and what OS?

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #4 by "Nikolai Devereaux" <yomama@u...> on Wed, 9 Oct 2002 10:00:35 -0700
> but eache time I go to localhost/test.php, the browser keeps on asking me
> to save to disk?  If I open the file that is saved, I see my exact script,
> I don't really know what I'm doing wrong.

You'll need to configure apache to run all your php files through the PHP
interpreter.  What's happening is that Apache sees a request for a .php file,
doesn't recognize the file extension, so it sends HTTP headers saying that
you're about to download an application of type xphp or something like that.

How you configure apache is largely up to you -- do you want it to run as a
module or as a CGI?  A module is a library loaded at run-time.  A CGI is an
executable program that Apahce calls each time a PHP script is requested.


BOTH versions are clearly documented here:
  http://www.php.net/manual/en/install.apache.php

for Unix
  http://www.php.net/manual/en/install.apache.php#install.apache.unix

and Windows
  http://www.php.net/manual/en/install.apache.php#install.apache.windows


take care,

nik

Message #5 by Jefferis Peterson <jefferis@p...> on Wed, 09 Oct 2002 13:11:48 -0400
Did you restart apache and/or computer?



On 10/9/02 6:09 PM, "Francois Desautels" <fdesautels@r...> wrote:

> I'm runnign mandrake 8.2, on an Athalon.  I went through the httpd.conf
> file, uncommenting the following, and adding index.php to the mod_dir.c
> section.
> 
> #AddType application/x-httpd-php .php
> #AddType application/x-httpd-php-source .phps
> 
> 
> <IfModule mod_dir.c>
>   DirectoryIndex index.php index.htm index.html
> </IfModule> 

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #6 by "Francois Desautels" <fdesautels@r...> on Wed, 9 Oct 2002 19:04:33
yes, I at first stopped Apache, then installed PHP
cd /usr/local/src/php-4.2.2
./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--enable-track-vars \
--with-xml
make
make install

I then restarted apache, and that is when I tried the test.php file.

> Did you restart apache and/or computer?



On 10/9/02 6:09 PM, "Francois Desautels" <fdesautels@r...> wrote:

> I'm runnign mandrake 8.2, on an Athalon.  I went through the httpd.conf
> file, uncommenting the following, and adding index.php to the mod_dir.c
> section.
> 
> #AddType application/x-httpd-php .php
> #AddType application/x-httpd-php-source .phps
> 
> 
> <IfModule mod_dir.c>
>   DirectoryIndex index.php index.htm index.html
> </IfModule> 

~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel .  xxx-xxx-xxxx
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year

Message #7 by "Gellings, C.O." <gellingsco@p...> on Fri, 11 Oct 2002 16:57:40 +0200
Francois,

After each command line you need to put a ;
i.e. for your code:

<html>
<body>
<? echo "hello world"; ?>
</body>
</html>

mth,
Carl

-----Original Message-----
From: Francois Desautels [mailto:fdesautels@r...]
Sent: 09 October 2002 17:42
To: beginning php
Subject: [beginning_php] When testing my PHP script, the browser asks to
save the file


Hi,

I've recently installed PHP4 on apache 1.3.20, I have a very basic
test.php script.

<html>
<body>
<? echo "hello world" ?>
</body>
</html>

but eache time I go to localhost/test.php, the browser keeps on asking me
to save to disk?  If I open the file that is saved, I see my exact script,
I don't really know what I'm doing wrong.



  Return to Index