Forum Moderators: phranque

Message Too Old, No Replies

apache and php problem

         

robsams

1:23 pm on Mar 28, 2006 (gmt 0)



Hi
I have recently installed apache web server and have been trying co connect to a database using php. The problem I'm having is that i can connect and insert data to mysql database if I use a php file and open it on the localhost eg [localhost...] but if I try to do anything like this with embedded php code in an html file this. does not work. Even <?php echo 'test';?> doesn't work anf if you view the page source the php code shows up in there which I'm sure is not right. Please help as I am completely stuck with this. Thanks

mack

6:51 pm on Mar 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



When you say you are embedding your php within an html file are you using the .php file extension?

By default files need to have a .php extension before they will be executed as php code.

The alternative is to force the server to render .html as if would. php

Try the following as a test.


<?php
echo 'Hello World!';
?>

Save the above as test.php and upload it to your server. Call test.php in your browser. This will let you know that php is being handled correctly.

Mack.