I'm trying to learn PHP since I need to build an application and the folks I'm helping are using a web server that doesn't support SQL Server.
SO, on my local machine In installed php, Apache, and MySQL.
I can run either http://localhost/info.php and it works fine, or http://127.0.0.1/info.php and IT also works fine. I even created a test.php that I can run THAT........
BUT, when I run an html file with php embedded I get the source code...... I've now wasted an entire <bleep> day going through web posts trying to find what configuration changes are needed. It STILL displays source code.......
And YES, in my httpd.conf I have
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
PHPIniDir "D:/Program Files/PHP/"
LoadModule php5_module "d:\Program Files\PHP\php5apache2_2.dll"
And YES, they point (as near as I can tell) to the actual places where those files are.
I've stopped and started Apache service every time I've made a change......
The files I'm running are in the htdocs subdirectory (which I presume is being pointed to correctly since I can do the http://localhost/file... and it works.
I'm not sure what changes I need to make to php.ini since my installation only had 1 .ini file, not several to choose from. But, I found a location in the php.ini for doc_root, which seems like something that should point somewhere, but mine is just doc_root =
SO, can somebody out there tell me, in clear, unambiguous, idiot-proof terms, what I have to do to get PHP and Apache to successfully run the php embedded in the html? Once I have that I'll start the next battle - getting it to talk to MySQL.
Xp Pro, PHP 5.2, Apache 2.2 STILL seeing source code
Moderator: General Moderators
Re: Xp Pro, PHP 5.2, Apache 2.2 STILL seeing source code
Why are you really specific about the files that do run, but vague about the ones you are having trouble with? When you say 'html file with php embedded' do you mean *.html files? So you want to treat .html files as php? Are you trying to run it at this address - 'http://localhost/myfile.html'?
Can't you just rename your .html files to .php files? If not try this:
It looks like your httpd.conf is not setup to do this. You might need to add the following lines to your httpd.conf
... Consider using WAMP (or MAMP for Macs). It's built to just work with no tinkering - especially worth a look if you are have issues integrating with mysql
Can't you just rename your .html files to .php files? If not try this:
It looks like your httpd.conf is not setup to do this. You might need to add the following lines to your httpd.conf
Code: Select all
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm... Consider using WAMP (or MAMP for Macs). It's built to just work with no tinkering - especially worth a look if you are have issues integrating with mysql
Re: Xp Pro, PHP 5.2, Apache 2.2 STILL seeing source code
>Why are you really specific about the files that do run, but vague about the ones you are having trouble with? When you say 'html file with php >embedded' do you mean *.html files? So you want to treat .html files as php? Are you trying to run it at this address -> 'http://localhost/myfile.html'?
I can only plead ignorance... Lemme try again.... I'm using the "headsupphp" book. It has an html file that puts up a form and lets me fill in some fields. It uses the <form method=post" action="filename.php"> to process [?] the form... Since it still displays the php source code, I stripped out everything but:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title in tab</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>testing</h2>
<p>A line to display:</p>
<form method="post" action="test.php">
<input type="submit" value="testbutton" name="submit" />
</form>
</body>
</html>
which calls a php file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phptab</title>
</head>
<body>
<h2>simple php</h2>
<?php
echo 'Thanks for the form.<br />';
?>
</body>
</html>
which displays source code instead of "running". The php works fine if I run it as http://localhost/test.php
I added the two additional AddType statements, restarted Apache..... No change.
I can only plead ignorance... Lemme try again.... I'm using the "headsupphp" book. It has an html file that puts up a form and lets me fill in some fields. It uses the <form method=post" action="filename.php"> to process [?] the form... Since it still displays the php source code, I stripped out everything but:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title in tab</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>testing</h2>
<p>A line to display:</p>
<form method="post" action="test.php">
<input type="submit" value="testbutton" name="submit" />
</form>
</body>
</html>
which calls a php file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phptab</title>
</head>
<body>
<h2>simple php</h2>
<?php
echo 'Thanks for the form.<br />';
?>
</body>
</html>
which displays source code instead of "running". The php works fine if I run it as http://localhost/test.php
I added the two additional AddType statements, restarted Apache..... No change.
Re: Xp Pro, PHP 5.2, Apache 2.2 STILL seeing source code
When the file is displayed in your web browser are you viewing it as 'http://localhost/myfile.html' or as 'file://c:\root\to\myfile.html'? (Check the address bar in your browser)
If you double clicked the file to open it in a browser it might be showing the file directly rather than having apache/php parsing it in between..
(Please include code within [ code] tags [ /code] or [ php] [ /php] (remove space after '['). This makes it easier to digest code)
If you double clicked the file to open it in a browser it might be showing the file directly rather than having apache/php parsing it in between..
(Please include code within [ code] tags [ /code] or [ php] [ /php] (remove space after '['). This makes it easier to digest code)
Re: Xp Pro, PHP 5.2, Apache 2.2 STILL seeing source code
As always, once someone knows the answer, it's simple..........
Which explains why every so often, the thing appeared to work......
Yes, I was double-clicking on the .html file rather than entering localhost/<file>.html
Didn't even know it'd make a difference........ That strikes me as something that should
be in the "learn php" books in BIG LETTERS.....
Which explains why every so often, the thing appeared to work......
Yes, I was double-clicking on the .html file rather than entering localhost/<file>.html
Didn't even know it'd make a difference........ That strikes me as something that should
be in the "learn php" books in BIG LETTERS.....