• <tfoot id='wIX9K'></tfoot>

        <legend id='wIX9K'><style id='wIX9K'><dir id='wIX9K'><q id='wIX9K'></q></dir></style></legend>

        <small id='wIX9K'></small><noframes id='wIX9K'>

          <bdo id='wIX9K'></bdo><ul id='wIX9K'></ul>

        <i id='wIX9K'><tr id='wIX9K'><dt id='wIX9K'><q id='wIX9K'><span id='wIX9K'><b id='wIX9K'><form id='wIX9K'><ins id='wIX9K'></ins><ul id='wIX9K'></ul><sub id='wIX9K'></sub></form><legend id='wIX9K'></legend><bdo id='wIX9K'><pre id='wIX9K'><center id='wIX9K'></center></pre></bdo></b><th id='wIX9K'></th></span></q></dt></tr></i><div id='wIX9K'><tfoot id='wIX9K'></tfoot><dl id='wIX9K'><fieldset id='wIX9K'></fieldset></dl></div>

        mysqli_query() 总是返回真

        时间:2023-07-29

      1. <small id='0CC8s'></small><noframes id='0CC8s'>

        <legend id='0CC8s'><style id='0CC8s'><dir id='0CC8s'><q id='0CC8s'></q></dir></style></legend>
          <i id='0CC8s'><tr id='0CC8s'><dt id='0CC8s'><q id='0CC8s'><span id='0CC8s'><b id='0CC8s'><form id='0CC8s'><ins id='0CC8s'></ins><ul id='0CC8s'></ul><sub id='0CC8s'></sub></form><legend id='0CC8s'></legend><bdo id='0CC8s'><pre id='0CC8s'><center id='0CC8s'></center></pre></bdo></b><th id='0CC8s'></th></span></q></dt></tr></i><div id='0CC8s'><tfoot id='0CC8s'></tfoot><dl id='0CC8s'><fieldset id='0CC8s'></fieldset></dl></div>

            <tbody id='0CC8s'></tbody>
          <tfoot id='0CC8s'></tfoot>

                • <bdo id='0CC8s'></bdo><ul id='0CC8s'></ul>

                • 本文介绍了mysqli_query() 总是返回真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我的表格:

                  <!DOCTYPE html>
                  <html>
                    <head>
                    </head>
                    <body>
                      <form action="register_ajax.php" method="get">
                      <input type="text" name="email">
                      <input type="submit" value="test">
                      </form>
                    </body>
                  </html>
                  

                  这是我的php代码:

                  <?php
                      $dbc = mysqli_connect("localhost","root","*******","continental_tourism") OR die(mysqli_connect_error());
                      $email = $_GET['email'];
                      $query = "SELECT email FROM customer_info WHERE email = '$email' ";
                      $r = mysqli_query($dbc, $query) OR die(mysqli_error($dbc));
                      if($r)
                          echo "Email address exists!";
                      else
                          echo "sss";
                  ?>
                  

                  如果我输入正确的(db 上的现有电子邮件)$r 为真.但是如果我输入不存在的电子邮件,那么 $r 也是如此.这是为什么?基本上我想检测空集.我该怎么做?

                  If I enter a correct(Existing email on db) $r is true. But if I enter non existing email, then also $r is true. Why is that? Basically I want to detect the empty set. How can I do it?

                  谢谢!

                  推荐答案

                  $r 只有在出现 SQL 错误时才会为假.否则它将始终返回一个对象,即使您的 SELECT 语句没有返回任何行.

                  $r will only be false if there was SQL error. Otherwise it will always return an object, even if no rows are returned by your SELECT statement.

                  使用mysqli_num_rows() 计算返回的行数.零表示没有人使用该电子邮件地址.

                  Use mysqli_num_rows() to count how many rows are returned. Zero means no one is using that email address.

                  if(mysqli_num_rows($r))
                      echo "Email address exists!";
                  else
                      echo "sss"; 
                  

                  这篇关于mysqli_query() 总是返回真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用php将阿拉伯语文本存储在mysql数据库中 下一篇:mysqli 持久连接

                  相关文章

                  最新文章

                    <bdo id='GiNkR'></bdo><ul id='GiNkR'></ul>
                • <legend id='GiNkR'><style id='GiNkR'><dir id='GiNkR'><q id='GiNkR'></q></dir></style></legend>
                  <i id='GiNkR'><tr id='GiNkR'><dt id='GiNkR'><q id='GiNkR'><span id='GiNkR'><b id='GiNkR'><form id='GiNkR'><ins id='GiNkR'></ins><ul id='GiNkR'></ul><sub id='GiNkR'></sub></form><legend id='GiNkR'></legend><bdo id='GiNkR'><pre id='GiNkR'><center id='GiNkR'></center></pre></bdo></b><th id='GiNkR'></th></span></q></dt></tr></i><div id='GiNkR'><tfoot id='GiNkR'></tfoot><dl id='GiNkR'><fieldset id='GiNkR'></fieldset></dl></div>

                  <small id='GiNkR'></small><noframes id='GiNkR'>

                  1. <tfoot id='GiNkR'></tfoot>