可能重複:
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given error在PHP選擇下一行
我有一個MySQL數據庫的記錄集,我試圖讓網頁上的選擇下一個和上一個按鈕。我有問題在PHP編碼,但是;任何幫助是極大的讚賞。
我的記錄沒有附加自動增量ID。
我的代碼如下:
$result = mysql_query($query) or die("Couldn't execute query");
$row_number = 1;
while ($row = mysql_fetch_assoc($result)) {
$row_number ++;
if ($row_number <= mysql_num_rows($result)) {
$nextRecord=mysql_data_seek($result,$row_number);
while ($nextRow = mysql_fetch_row($nextRecord)) {
echo $nextRow['family_accession_number'];}
當我嘗試運行腳本,下面的消息出來了:
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 2 is invalid for MySQL result index 3 (or the query data is unbuffered) in C:\xampp\htdocs\survey\continuetitle.php on line 23
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\survey\continuetitle.php on line 25
第23行是:$nextRecord=mysql_data_seek($result,$row_number);
謝謝!
編輯: 我改變while ($nextRow = mysql_fetch_row($nextRecord)) {
到
while ($nextRow = mysql_fetch_row($result)) {
但線發生同樣的錯誤23
編輯:
在SQL查詢發現錯誤,只返回一行。
也許你應該解釋爲什麼你想讓你的代碼到當前遊標的末尾。 – 2010-01-19 02:47:02
對不起,我在我的SQL $查詢中發現一個錯誤;這就是爲什麼它不起作用。 – Tim 2010-01-19 02:56:52