0
我想部署一个网站,但当PHP/MySql代码在服务器上时出现错误。它在开发中运行良好,但不在生产中运行。PHP正在打破我的代码
我的代码下来到这里,没有任何问题:
<div class="content">
<section class="col1">
<h1>Read reviews or write us one</h1>
</section>
<section class="col2">
<button type="button" class="read">Read Reviews</button>
<?php include ('display.php'); ?>
然后当我检查源代码,HTML只是停在那里。我猜有什么毛病我在文件Display.php的PHP,它看起来像这样:
<?php
$con = mysql_connect('localhost','communi3_root',"password");
mysql_select_db('communi3_cfds','[email protected]',"password") or die(mysql_error());
$query = "select * from reviews";
$result = mysql_query($query)or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<table class='displayReviews' border='1' style='width:100%;'>";
echo "<tr stlye='display:block;margin:0em auto;'><th>Name</th><th>Review</th><th>Date</th></tr>";
while ($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['monicker'];
echo "</td><td>";
echo $row['review'];
echo "</td><td>";
echo $row['date'];
echo "</td></tr>";
}
echo "</table>";
mysql_close();
?>
'echo',不'$ echo' –
我后当浪费时也做到了。呃,OP如果你看不到错误信息,你打算如何调试你的任何代码?你需要去找到你的服务器上的php.ini文件,并打开错误和警告(它解释了如何),然后重新启动Apache,所以当你正在开发这个,你可以看到发生了什么。否则...祝你好运。 – joshstrike
'mysql_select_db()'与'mysql_connect()'不一样......你连接了两次,但第二次使用了错误的函数。另外,你不应该使用不推荐的'mysql_ *'函数。改为使用'PDO'或'MySQLi'。此外,将“mysql_error()”打印到页面意味着人们会看到它,如果出现问题,这是非常不安全的。您应该记录错误。 Ehm和'stlye'不是有效的HTML属性。我不打算再编辑这个评论...你应该真的清理你的代码... –