GVKun编程网logo

mysqli_query()至少需要2个参数,其中1个是给定的?(mysql至少有一个)

14

此处将为大家介绍关于mysqli_query的详细内容,并且为您解答有关至少需要2个参数,其中1个是给定的?的相关问题,此外,我们还将为您介绍关于mysqli_error()期望恰好有1个参数,给定0

此处将为大家介绍关于mysqli_query的详细内容,并且为您解答有关至少需要2个参数,其中1个是给定的?的相关问题,此外,我们还将为您介绍关于mysqli_error()期望恰好有1个参数,给定0、mysqli_query() 和 & mysqli_fetch_array() mysqli_result,期望参数 1 为空、mysqli_query()至少需要2个参数和mysqli_query():空查询错误消息、mysqli_query()至少需要2个参数,给定1个(查看:C: xampp htdocs buku-tamu resources views proses.blade.php),请帮助我的有用信息。

本文目录一览:

mysqli_query()至少需要2个参数,其中1个是给定的?(mysql至少有一个)

mysqli_query()至少需要2个参数,其中1个是给定的?(mysql至少有一个)

每次运行此php时,我都会不断收到相同的3个错误。我不知道我在做什么错,有人可以帮忙吗?

错误如下:

[2014年5月5日19:20:50美国/芝加哥]
PHP警告:mysqli_query()至少需要2个参数,第10行的/home/sagginev/public_html/Nutrifitness/search.php中提供了1个参数

[2014年5月5日19:20:50美国/芝加哥]
PHP警告:mysqli_num_rows()期望参数1为mysqli_result,在第11行的/home/sagginev/public_html/Nutrifitness/search.php中给出的null

[2014年5月5日19:20:50美国/芝加哥]
PHP警告:mysqli_num_rows()期望参数1为mysqli_result,在第16行的/home/sagginev/public_html/Nutrifitness/search.php中给出的null

这是我的代码

enter code here

    <?php    $con=mysqli_connect(''localhost'',''sagginev_rob'',''122989'',''sagginev_Nutrifitness'');    if (mysqli_connect_errno()) // Check connection      {   echo "Failed to connect to MySQL: " . mysqli_connect_error();  }        if(!isset($_POST[''search''])) {    header("Location:home.php");    }    $search_sql="Select * FROM Questions WHERE username LIKE ''%".$_POST[''search'']."%'' OR feedback LIKE ''%".$_POST[''search'']."%''";    $search_query=mysqli_query($search_sql);    if(mysqli_num_rows($search_query)!=0) {    $search_rs=mysqli_fetch_assoc($search_query);    }    ?>    <H2> Search Results</H2>    <?php if(mysqli_num_rows($search_query)!=0) {     do { ?>     <p><?php echo $search_rs[''name'']; ?> </p>    <?php } while ($search_rs=mysqli_fetch_assoc($search_query));    } else {       echo "No results found";    } ?>    <form>    <br>    <input type="button" value="Go Back Home" onClick="parent.location=''http://sagginevo.com/Nutrifitness/home.php''">    </form>

答案1

小编典典

错误消息很清楚。mysqli_query()需要 两个 参数。您只提供一个。当您看到这样的错误消息时,您 要做第一件事就是阅读 手册 。如果这样做,您将看到必须提供MySQLi链接作为第一个参数:

$search_query=mysqli_query($con, $search_sql);

mysqli_error()期望恰好有1个参数,给定0

mysqli_error()期望恰好有1个参数,给定0

我试图让我的头围绕mysql。谁能告诉我为什么这个MySQL查询无法正常工作?我收到以下错误:

警告:mysqli_error()期望恰好有1个参数,第11行的/home/freebet2/public_html/test.php中给出的参数为0

test.php

<?php
        require_once($_SERVER['DOCUMENT_ROOT'].'/includes/db.php');
        $conn = db_connect();
        $result = $conn->query("ALTER TABLE users ADD COLUMN refer_old INT(10) AFTER refer_id");

              if(!$result){
                 echo "Error with MySQL Query: ".mysqli_error();
             }
        ?>

db.php

 <?php

    function db_connect() {
       $result = new mysqli('localhost','user','password','db');
       if (!$result) {
         throw new Exception('Could not connect to database server');
       } else {
         return $result;
       }
    }

    ?>

如果我将alter string更改为:之类的$result = $conn->query("SELECT * FROM users refer_id");原因,我不会收到任何错误。

mysqli_query() 和 & mysqli_fetch_array() mysqli_result,期望参数 1 为空

mysqli_query() 和 & mysqli_fetch_array() mysqli_result,期望参数 1 为空

如何解决mysqli_query() 和 & mysqli_fetch_array() mysqli_result,期望参数 1 为空?

警告:MysqLi_query() 期望参数 1 为 MysqLi,第 101 行 C:\xampp\path\products.PHP 中给出的 null

警告:MysqLi_fetch_array() 期望参数 1 为 MysqLi_result,第 10 行 C:\xampp\path\products.PHP 中给出的 null

数据连接文件

 <?PHP
  $conn = MysqLi_connect("localhost","root","","mystore");
    
 if($conn){
  //echo "Database has been configured.";
   }
  else{
  echo "You have no connection with database";
  } 
    

查询文件(products.PHP)

 <th>Sr#</th>
 <th>Product Name</th>
  <th>Product Desc</th>
 <th>Product Price</th>
 <th>View | Update | Delete</th>
   </tr>
  </thead>
   <tbody>
  <?PHP
   $i = 0;
  $query = "select * from products";
   $run = MysqLi_query($conn,$query);
   while($row = MysqLi_fetch_array($run)){
  $i++;
  ?>
  <tr>
   <td><?PHP echo $i; ?></td>
   <td><?PHP echo $row[''product_name'']; ?></td>
    <td><?PHP echo $row[''product_desc'']; ?></td>
   <td><?PHP echo $row[''product_price'']; ?></td>
     <td></td>
   <?PHP } ?>
   </tbody>
    </table>
    

在上面提到的代码行中包含两个单独的文件。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

mysqli_query()至少需要2个参数和mysqli_query():空查询错误消息

mysqli_query()至少需要2个参数和mysqli_query():空查询错误消息

运行此代码时出现4个错误,这些错误将用户的电子邮件地址添加到名为ecommerce的表中称为的数据库中subscriptions

$ con = new mysqli(’localhost’,’root’,’‘,’ecommerce’);

if (!$con) {
    die('Could not connect: ' . mysql_error());
}

$errors = array();
if($_POST)
    {
        if(empty($_POST['email']))
        {
            $errors['email1'] = "<p>Dont forget to write your email!</p>";
        }else {
            $email = test_input($_POST["email"]);

            // check if e-mail address is well-formed
            if (!filter_var($email,FILTER_VALIDATE_EMAIL)) {
                $errors['email2'] = "<p>Something wrong is with your email</p>"; 
            }else{

                // check if the email already exists
                $query = mysqli_query("SELECT * FROM subscriptions WHERE email='$email'");
                if(mysqli_num_rows($query) > 0){
                    $errors['email3'] = "<p>Your had been registered before!</p>";
                }
            }
        }

        //check errors
        if(count($errors) == 0)
        {
            $insert_email = mysqli_query("INSERT INTO subscriptions (email) VALUES ('$email')");
            $insert_email = mysqli_query($con,$insert_email);
            $success = "<script>alert('Your email was successfully added to our database!')</script>";
        }
    }

function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>
<form action="" method="POST"dir="ltr">
                                <input type="text" name="email" placeholder="Your email address" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>"/>
                                <button name="submit" type="submit"><i></i></button>
                                <p><?php if(isset($errors['email1'])) echo $errors['email1']; ?></p>
                                <p><?php if(isset($errors['email2'])) echo $errors['email2']; ?></p>
                                <p><?php if(isset($errors['email3'])) echo $errors['email3']; ?></p>
                                <p><?php if(isset($success)) echo $success; ?></p>
                                <?php if(count($errors) == 0){echo "<p id='para' dir='rtl'>You can add your email to our emailsshow list.</p>";}?>
</form>

错误是这样的:

警告:mysqli_query()至少需要2个参数,第27行给出1个

第27行:

$ query = mysqli_query(“ SELECT * FROM subscriptions where where email =’$
email’”);

警告:mysqli_num_rows()期望参数1为mysqli_result,第28行给出null

第28行:

if(mysqli_num_rows($ query)> 0){

警告:mysqli_query()至少需要2个参数,第37行给出1个

第37行:

$ insert_email = mysqli_query(“ INSERT INTO subscriptions(电子邮件)VALUES(’$
email’)”);

警告:mysqli_query():第38行的查询为空

38行:

$ insert_email = mysqli_query($ con,$ insert_email);

我是这个论坛的新手,如果您可以帮助我,那么我真的很想做…最好,谢谢!

mysqli_query()至少需要2个参数,给定1个(查看:C: xampp  htdocs  buku-tamu  resources  views  proses.blade.php),请帮助我

mysqli_query()至少需要2个参数,给定1个(查看:C: xampp htdocs buku-tamu resources views proses.blade.php),请帮助我

如何解决mysqli_query()至少需要2个参数,给定1个(查看:C:\ xampp \ htdocs \ buku-tamu \ resources \ views \ proses.blade.php),请帮助我?

我正在创建一个登录页面,该页面提交后,过程页面将出现错误,如图片中的错误。我寻求帮助,谢谢。 $ tampil = MysqLi_query(“ SELECT * FROM pengunjung”)部分发生错误; enter image description here

                <h3>DAFTAR</h3>

                <h3>Data Yang Di Input : </h3>

                <table border="1" width="100%">

                    <tr>

                        <td>No.</td>

                        <td>Nama</td>

                        <td>Kontak</td>

                        <td>Asal</td>

                        <td>Tujuan</td>

                        <td>Deskripsi</td>

                    </tr>

                    <?PHP

                    @include(''buku-tamu/koneksidatabase.PHP'');

                    $no=1;

                    $tampil=MysqLi_query("SELECT * FROM pengunjung");

                    while($data=MysqL_fetch_array($tampil)){

                    ?>

                    <tr>

                        <td><?PHP echo $no++;?></td>

                        <td><?PHP echo $data[''nama_pengunjung''];?></td>

                        <td><?PHP echo $data[''kontak_pengunjung''];?></td>

                        <td><?PHP echo $data[''asal_pengunjung''];?></td>

                        <td><?PHP echo $data[''tujuan_pengunjung''];?></td>

                        <td><?PHP echo $data[''deskripsi_pengunjung''];?></td>

                    </tr>

                    <?PHP

                }

                 ?>

                </table>

                <a href="/daftar">Kembali</a>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

关于mysqli_query至少需要2个参数,其中1个是给定的?的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于mysqli_error()期望恰好有1个参数,给定0、mysqli_query() 和 & mysqli_fetch_array() mysqli_result,期望参数 1 为空、mysqli_query()至少需要2个参数和mysqli_query():空查询错误消息、mysqli_query()至少需要2个参数,给定1个(查看:C: xampp htdocs buku-tamu resources views proses.blade.php),请帮助我等相关知识的信息别忘了在本站进行查找喔。

本文标签: