简体   繁体   中英

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错误

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?

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

Try:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM