我尝试部署网站但是当PHP / MySql代码进入服务器时出现错误。它在开发中工作得很好,但在生产中却没有。
我的代码落到了这里,没有任何问题:
<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就停在那里。我猜测我的PHP在display.php文件中出现了问题,如下所示:
<?php
$con = mysql_connect('localhost','communi3_root',"password");
mysql_select_db('communi3_cfds','communi3@localhost',"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();
?>
答案 0 :(得分:0)
<?php
$con = mysql_connect('localhost','communi3_root',"password");
mysql_select_db('communi3_cfds',$con) 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();
?>