我想使用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