• PHP Help PHP Coding
  • error Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean

$result = mysqli_query($link, $sql);
while ($dbarr = mysqli_fetch_array($result))
{

  $count++;     
} $itemno = $count + 1;

what the..................

    From [man]mysqli_query[/man]:

    Returns FALSE on failure

    To see why there was a failure, see [man]mysqli_error[/man].

    But you do know that the database is itself capable of counting the number of matched records, right?

      <!DOCTYPE html>
      <html>
      <head>
      <meta charset="utf-8">
      <title>&#3615;&#3629;&#3619;&#3660;&#3617;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;</title>
      </head>
      <body>
      <h2>Web Board</h2>
      <form name="form1" method="post" action="Insert_question.php">
      &#3627;&#3633;&#3623;&#3586;&#3657;&#3629;&#3586;&#3629;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657; : <input type="text" name="qtopic"><p>
      <textarea name="qdetail" cols="75" rows="10"></textarea><p>
      &#3594;&#3639;&#3656;&#3629;&#3612;&#3641;&#3657;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;: <input type="text" name="qname"><p>
      <input type="submit" name="Submit" value="&#3626;&#3656;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;">
      <input type="reset" name="Submit2" value="&#3618;&#3585;&#3648;&#3621;&#3636;&#3585;">
      </form>

      </body>
      </html>

      [ATTACH]5490[/ATTACH]

      <?php
      $topic = $POST["qtopic"];
      $detail = $
      POST["qdetail"];
      $name = $_POST["qname"];

      //&#3585;&#3635;&#3627;&#3609;&#3604;&#3594;&#3639;&#3656;&#3629;&#3650;&#3630;&#3626;&#3605;&#3660;&#3649;&#3621;&#3632; user name
      $link = mysqli_connect("localhost","root");
      mysqli_set_charset($link,'utf8');
      $sql = "board"; //&#3648;&#3619;&#3637;&#3618;&#3585;&#3651;&#3594;&#3657;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621; bord
      $result = mysqli_query($link,$sql);
      $sql = "Select * from question;"; //&#3604;&#3638;&#3591;&#3607;&#3640;&#3585;&#3648;&#3619;&#3588;&#3588;&#3629;&#3619;&#3660;&#3604;&#3592;&#3634;&#3585;&#3605;&#3634;&#3619;&#3634;&#3591; Question
      $count = 0; //&#3585;&#3635;&#3627;&#3609;&#3604;&#3592;&#3635;&#3609;&#3623;&#3609;&#3588;&#3635;&#3606;&#3634;&#3617;&#3648;&#3619;&#3636;&#3656;&#3617;&#3605;&#3657;&#3609;&#3651;&#3627;&#3657;&#3648;&#3607;&#3656;&#3634;&#3585;&#3633;&#3610; 0
      $result = mysqli_query($link, $sql);

      while ($dbarr = mysqli_fetch_array($result))
      {

      $count++; //&#3623;&#3609;&#3621;&#3641;&#3611;&#3648;&#3614;&#3639;&#3656;&#3629;&#3609;&#3633;&#3610;&#3592;&#3635;&#3609;&#3623;&#3609;&#3588;&#3635;&#3606;&#3634;&#3617;&#3607;&#3637;&#3656;&#3617;&#3637;&#3629;&#3618;&#3641;&#3656;&#3607;&#3633;&#3657;&#3591;&#3627;&#3617;&#3604;&#3651;&#3609;&#3605;&#3634;&#3619;&#3634;&#3591;
      }
      $itemno = $count + 1; //&#3648;&#3614;&#3636;&#3656;&#3617;&#3592;&#3635;&#3609;&#3623;&#3609;&#3586;&#3657;&#3629;&#3588;&#3635;&#3606;&#3634;&#3617;&#3586;&#3638;&#3657;&#3609;&#3629;&#3637;&#3585;&#3627;&#3609;&#3638;&#3656;&#3591;
      //&#3648;&#3614;&#3636;&#3656;&#3617;&#3627;&#3617;&#3634;&#3618;&#3648;&#3621;&#3586;&#3586;&#3657;&#3629;, &#3627;&#3633;&#3623;&#3586;&#3657;&#3629;, &#3619;&#3634;&#3618;&#3621;&#3632;&#3648;&#3629;&#3637;&#3618;&#3604;, &#3594;&#3639;&#3656;&#3629;&#3612;&#3641;&#3657;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;, 0 &#3621;&#3591;&#3651;&#3609;&#3605;&#3634;&#3619;&#3634;&#3591; Question
      $sql = "Insert into question Values($itemno,'$topic','$detail','$name' 0);";
      $result = mysqli_query($link,$sql);
      if ($result) {
      echo "&#3648;&#3614;&#3636;&#3656;&#3617;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;&#3621;&#3591;&#3626;&#3641;&#3656;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3649;&#3621;&#3657;&#3623;<p>";
      mysqli_close($link);
      }
      else {
      echo "&#3652;&#3617;&#3656;&#3626;&#3634;&#3617;&#3634;&#3619;&#3606;&#3648;&#3614;&#3636;&#3656;&#3617;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;&#3621;&#3591;&#3651;&#3609;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3652;&#3604;&#3657;<p>";
      }
      echo "<a href=show_question.php>&#3649;&#3626;&#3604;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3607;&#3633;&#3657;&#3591;&#3627;&#3617;&#3604;</a><br>";
      echo "<a href=form_question.html>&#3585;&#3621;&#3633;&#3610;&#3626;&#3641;&#3656;&#3627;&#3609;&#3657;&#3634;&#3615;&#3629;&#3619;&#3660;&#3617;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;</a><br>";
      ?>

      It is correct

      Screenshot_1.png

        <html>
        <head>
        <meta charset="utf-8">
        <title>&#3615;&#3629;&#3619;&#3660;&#3617;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;</title>
        </head>
        <body>
        <h2>Web Board</h2>
        <form name="form1" method="post" action="Insert_question.php">
        &#3627;&#3633;&#3623;&#3586;&#3657;&#3629;&#3586;&#3629;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657; : <input type="text" name="qtopic"><p>
        <textarea name="qdetail" cols="75" rows="10"></textarea><p>
        &#3594;&#3639;&#3656;&#3629;&#3612;&#3641;&#3657;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;: <input type="text" name="qname"><p>
        <input type="submit" name="Submit" value="&#3626;&#3656;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;">
        <input type="reset" name="Submit2" value="&#3618;&#3585;&#3648;&#3621;&#3636;&#3585;">
        </form>

        </body>
        </html>

        [ATTACH]5490[/ATTACH]

        <?php
        $topic = $POST["qtopic"];
        $detail = $
        POST["qdetail"];
        $name = $_POST["qname"];

        //&#3585;&#3635;&#3627;&#3609;&#3604;&#3594;&#3639;&#3656;&#3629;&#3650;&#3630;&#3626;&#3605;&#3660;&#3649;&#3621;&#3632; user name
        $link = mysqli_connect("localhost","root");
        mysqli_set_charset($link,'utf8');
        $sql = "board"; //&#3648;&#3619;&#3637;&#3618;&#3585;&#3651;&#3594;&#3657;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621; bord
        $result = mysqli_query($link,$sql);
        $sql = "Select * from question;"; //&#3604;&#3638;&#3591;&#3607;&#3640;&#3585;&#3648;&#3619;&#3588;&#3588;&#3629;&#3619;&#3660;&#3604;&#3592;&#3634;&#3585;&#3605;&#3634;&#3619;&#3634;&#3591; Question
        $count = 0; //&#3585;&#3635;&#3627;&#3609;&#3604;&#3592;&#3635;&#3609;&#3623;&#3609;&#3588;&#3635;&#3606;&#3634;&#3617;&#3648;&#3619;&#3636;&#3656;&#3617;&#3605;&#3657;&#3609;&#3651;&#3627;&#3657;&#3648;&#3607;&#3656;&#3634;&#3585;&#3633;&#3610; 0
        $result = mysqli_query($link, $sql);

        while ($dbarr = mysqli_fetch_array($result))
        {

        $count++; //&#3623;&#3609;&#3621;&#3641;&#3611;&#3648;&#3614;&#3639;&#3656;&#3629;&#3609;&#3633;&#3610;&#3592;&#3635;&#3609;&#3623;&#3609;&#3588;&#3635;&#3606;&#3634;&#3617;&#3607;&#3637;&#3656;&#3617;&#3637;&#3629;&#3618;&#3641;&#3656;&#3607;&#3633;&#3657;&#3591;&#3627;&#3617;&#3604;&#3651;&#3609;&#3605;&#3634;&#3619;&#3634;&#3591;
        }
        $itemno = $count + 1; //&#3648;&#3614;&#3636;&#3656;&#3617;&#3592;&#3635;&#3609;&#3623;&#3609;&#3586;&#3657;&#3629;&#3588;&#3635;&#3606;&#3634;&#3617;&#3586;&#3638;&#3657;&#3609;&#3629;&#3637;&#3585;&#3627;&#3609;&#3638;&#3656;&#3591;
        //&#3648;&#3614;&#3636;&#3656;&#3617;&#3627;&#3617;&#3634;&#3618;&#3648;&#3621;&#3586;&#3586;&#3657;&#3629;, &#3627;&#3633;&#3623;&#3586;&#3657;&#3629;, &#3619;&#3634;&#3618;&#3621;&#3632;&#3648;&#3629;&#3637;&#3618;&#3604;, &#3594;&#3639;&#3656;&#3629;&#3612;&#3641;&#3657;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;, 0 &#3621;&#3591;&#3651;&#3609;&#3605;&#3634;&#3619;&#3634;&#3591; Question
        $sql = "Insert into question Values($itemno,'$topic','$detail','$name' 0);";
        $result = mysqli_query($link,$sql);
        if ($result) {
        echo "&#3648;&#3614;&#3636;&#3656;&#3617;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;&#3621;&#3591;&#3626;&#3641;&#3656;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3649;&#3621;&#3657;&#3623;<p>";
        mysqli_close($link);
        }
        else {
        echo "&#3652;&#3617;&#3656;&#3626;&#3634;&#3617;&#3634;&#3619;&#3606;&#3648;&#3614;&#3636;&#3656;&#3617;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;&#3621;&#3591;&#3651;&#3609;&#3600;&#3634;&#3609;&#3586;&#3657;&#3629;&#3617;&#3641;&#3621;&#3652;&#3604;&#3657;<p>";
        }
        echo "<a href=show_question.php>&#3649;&#3626;&#3604;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3607;&#3633;&#3657;&#3591;&#3627;&#3617;&#3604;</a><br>";
        echo "<a href=form_question.html>&#3585;&#3621;&#3633;&#3610;&#3626;&#3641;&#3656;&#3627;&#3609;&#3657;&#3634;&#3615;&#3629;&#3619;&#3660;&#3617;&#3605;&#3633;&#3657;&#3591;&#3585;&#3619;&#3632;&#3607;&#3641;&#3657;&#3651;&#3627;&#3617;&#3656;</a><br>";
        ?>

        It is correct

          Why should I do you work for you if you just ignore everything I say?

            Write a Reply...