我想使用PHP和MySQL在我手工制作的网站上发表评论。我有存储在我的数据库中的意见,但是当我试图将其选中我的网站抛出了这个错误,MySQL PHP SELECT抛出一个错误?
mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/a9210109/public_html/comments.php on line 16
到目前为止我的代码是低于
<?php
$comment = $_POST['comment'];
$mysql_host = "";
$mysql_database = "";
$mysql_user = "";
$mysql_password = "";
mysql_connect($mysql_host,$mysql_user,$mysql_password);
@mysql_select_db($mysql_database) or die("Unable to select database");
$CreateTable = "CREATE TABLE comments (comment VARCHAR(255), time VARCHAR(255));";
mysql_query($CreateTable);
$UseComment = "INSERT INTO comments VALUES ('$comment')";
mysql_query($UseComment);
$SelectComments = "SELECT * FROM comments";
$comments = mysql_query($SelectComments);
$num=mysql_numrows($comments);
$variable=mysql_result($comments,$i,"comment");
mysql_close();
?>
<a href="#" onclick="toggle_visibility('hidden');">Show/Hide Comments</a>
<?php
$i=0;
while ($i < $num) {
$comment=mysql_result($comments,$i,"comment");
echo "<div id='hidden' style='display:none'><h3>$comment</h3></div>";
$i++;
}
?>
谢谢,那个被注意到 – orano10000