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 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了