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

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)
    {
    }
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题