Ruben Martinez Jr.
Ruben Martinez Jr.

Reputation: 3110

PHP+HTML Error; Displays PHP code instead of processing it

For example, testing the code:

<HTML>  
<BODY>
<?php
$connect = mysql_connect("localhost", "root", "password") or
die ("Hey loser, check your server connection.");
mysql_select_db("school");
$quey1="select * from student";
$result=mysql_query($quey1) or die(mysql_error());
?>
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Student Record</EM></caption>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Class</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['stud_id'];
echo "</td><td>";
echo $row['stud_name'];
echo "</td><td>";
echo $row['stud_class'];
echo "</td></tr>";
}
echo "</table>";
?>
</BODY>
</HTML>

Gives me: PHP Error

I've also experienced the error in that using doesn't work, while hello world";?> in an html page will display 'hello world";?>' on the page. Not sure quite what is wrong...Anyone have a clue?

Upvotes: 0

Views: 286

Answers (2)

Andreas Wong
Andreas Wong

Reputation: 60516

You can't open a html file directly from your disk and expects your browser to interpret all those php scripts.

You need to actually install a web server like apache with php interpreter and point your browser to the url of your local apache installation docroot.

Upvotes: 1

Corbin
Corbin

Reputation: 33437

You need to access the file through the web server, not directly on your disk.

Try:

http://localhost/pp-homecheck/DailyLog/dailylog_new.php

Upvotes: 6

Related Questions