dongni9825 2015-06-15 09:59
浏览 157
已采纳

mysql_data_seek无法正常工作

my code is,

$query3     =   "SELECT * FROM db_exam_skip WHERE user='$session'";
$result3        =   mysql_query($query3) or die(mysql_error());
$length3        =   mysql_num_rows($result3);
while($rows3    =   mysql_fetch_array($result3))
{
    $query1 =   "SELECT * FROM db_exam_questions WHERE id='$rows3[ques_id]'";
    $result1   =    mysql_query($query1) or die(mysql_error());
    $length1   =    mysql_num_rows($result1);
}

if(isset($_POST['next']))
    {
        if(isset($_SESSION['list']))
        {
            mysql_data_seek($result1,$_SESSION['list']);
        }
        else
        {
            $list       =   $_POST['list'];
            mysql_data_seek($result1,$list);
        }
    }

<?php
        while($rows1    =   mysql_fetch_row($result1))
        {
            $start  =   $rows1[0];
            $_SESSION['start']  =   $start;
    ?>
 <form action="" method="post">
    <p style="font-size:20px;font-weight:bold"><?php echo $rows1[5]; ?></p>
    <ul style="list-style-type:none">
        <input type='hidden' name='number' value='<?php echo $_SESSION['order']++; ?>' />
        <input type='hidden' name='list' value='<?php echo $_SESSION['list']++; ?>' />
        <input type='hidden' name='ques_id' value='<?php echo $rows1[0]; ?>' />
        <input type='hidden' name='correct' value='<?php echo $rows1[10]; ?>' />
        <li><input type="radio" name="answer" value="1" /> <?php echo $rows1[6]; ?> <br><br>
        <input type="radio" name="answer" value="2" /> <?php echo $rows1[7]; ?> <br><br>
        <input type="radio" name="answer" value="3" /> <?php echo $rows1[8]; ?> <br><br>
        <input type="radio" name="answer" value="4" /> <?php echo $rows1[9]; ?> <br></li>
    </ul>
  <input type="submit" class="button4" value="Next" name="next" />
</form>
    <?php
    break;
        }
    ?>

my question is, after the first question is loaded, when i press next button to load the second question I am getting the below error.

Warning: mysql_data_seek(): Offset 2 is invalid for MySQL result index 8 (or the query data is unbuffered) in C:\wamp\www\Albert\ICAMS\start_skip_question.php on line 15

I have tried a lot to solve this error. But till now no success. Is there any method to solve. Any help will be appreciated.

Thank you.

  • 写回答

1条回答 默认 最新

  • dtxooq1020 2015-06-15 11:05
    关注

    I guess the result set is empty.I think query is returning empty set. You will get this error if result set is empty check the PHP DOCS

    First check if you are getting ant rows from the result

    if (mysqli_num_rows($sql) > 0)
    {
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?