繁体   English   中英

PHP + HTML错误; 显示PHP代码而不是对其进行处理

[英]PHP+HTML Error; Displays PHP code instead of processing it

例如,测试代码:

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

给我: PHP错误

我还遇到了一个错误,即使用不起作用,而html页面中的hello world“;?>将在页面上显示'hello world”;?>'。 不确定到底出了什么问题...有人知道了吗?

您需要通过Web服务器而不是直接在磁盘上访问文件。

尝试:

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

您无法直接从磁盘打开html文件,并且希望浏览器能够解释所有这些php脚本。

您实际上需要使用php解释器安装诸如apache之类的Web服务器并将浏览器指向本地apache安装docroot的url。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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