displying a page with php?

windows

Guest
I configured php to work with apache the best I can. I made a .php file and saved it in htdocs of apache. The file contained this code:<br />
<br />
<html><br />
<head><br />
<title>PHP Test</title><br />
</head><br />
<body><br />
<?php echo "<p>Hello World</p>"; ?><br />
</body><br />
</html><br />
<br />
I access it with this url, <!-- m --><a class="postlink" href="http://localhost/hello.php">http://localhost/hello.php</a><!-- m -->. When viewed in a browser, it shows all of the code. It shouldn't be showing <?php echo "";?>.<br />
<br />
What do I have configured wrong? I've been trying to find the information, but there is soo much to read, I don't know where to start.<!--content-->add these to the end of your httpd.conf file:<br />
<br />
LoadModule php4_module c:/php/sapi/php4apache2.dll<br />
AddType application/x-httpd-php .php<br />
<br />
obv replacing the correct paths etc<!--content-->I already have that there, sorta. This is what I have.<br />
<br />
LoadModule php4_module c:/php/sapi/php4apache.dll<br />
AddModule mod_php4.c<br />
AddType application/x-httpd-php .php<!--content-->have you recently added those? you'll need to restart apache if you have.<br />
<br />
not sure what else to suggest - obviously your web server isnt parsing the PHP file, and with that AddType line apache should take responsibility for it.<br />
<br />
a puzzler....<!--content-->Yeah, it was restarted. Maybe some files are in the wrong place? When I run a test on apache, it says everything is fine, though.<!--content-->I think that page didn't work because it was mixed in with html, maybe somethign is configured wrong there. I've been making pages with just php code. I wrote <?php phpinfo(); ?><br />
and alot of info came up, pretty cool.<!--content-->no theres no problem with mixing HTML and PHP code in together. And if your phpinfo page worked fine then that's even odder. Of course if you're putting PHP in with the HTML then you need to call the file x.php, but you've already said you've done that, which means it should be parsing it.<br />
<br />
About all i can think of is that you might be using a "WISIWIG" editor, like something like frontpage or dreamweaver? If that's the case then it might not be set up to save files as PHP files, and as such is actulaly saving your files with "HTML Special Characters" : in that case it wouldnt actually save <?PHP etc in your php file, but would save &lt;, whihc is the HTML code for th left tag, and would stop it from being parsed by the php code.<br />
<br />
Could that be the case? What happens when you view the source of the generated HTML?<!--content-->That must be it then! It is editing with dreamweaver. I would like to use just notepad, but by default it keeps' using dreamweaver. Also I looked at the source on the page and there were alot of < infront of each tag name.<!--content-->that'll be it then - i use dreamweaver too. I used to use notepad but the colouring features in dreamweave make it so much easier, i changed to that (i dont use any of the dreamweaver tools, just it's colouring.)<br />
<br />
couple of things to note:<br />
In edit / preferences / accessibility, make sure code colouring is set for php<br />
make sure php is added to the code view list in file types<br />
on the main screen, make sure the "code view" mode is selected, otherwise it will do it's htmlspecial chars trick.<br />
<br />
you'll find it so much easier in dreamweaver than in notepad, believe me.<!--content-->
 
Back
Top