警告:mysqli_query()期望参数1为mysqli,字符串为in [英] Warning: mysqli_query() expects parameter 1 to be mysqli, string given in
问题描述
<?php
require_once 我收到了标题中的警告'conn.php';
require_once'http.php';
if(isset($ _ REQUEST ['action'])){
switch($ _REQUEST ['action']){
case'Login':
if(isset($ _ POST ['email'])
和isset($ _ POST ['passwd'])
{
$ sql =SELECT user_id,access_lvl,name。FROM cms_users。WHERE email ='。 $ _POST ['email']。 。
AND passwd ='。 $ _POST ['passwd']。 ;
$ result = mysqli_query($ sql,$ conn)或死('无法查找用户信息''mysql_error());
正如您所传递的错误一样mysqli_query的参数不正确。假设 $ conn
是您的mysqli连接,在某些时候由新建mysqli()
应该是:
您正在调用它的方式是传递一个字符串, $ sql
作为第一个参数。
I got the warning meantioned in the title and my code is here:
<?php
require_once 'conn.php';
require_once 'http.php';
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'Login':
if (isset($_POST['email'])
and isset($_POST['passwd']))
{
$sql = "SELECT user_id, access_lvl,name "."FROM cms_users"."WHERE email='" . $_POST['email'] . "' " .
"AND passwd='" . $_POST['passwd'] . "'";
$result = mysqli_query($sql, $conn) or die('Could not look up user information; ' . mysql_error());
It's exactly as the error states as you're passing arguments to mysqli_query incorrectly. Assumming $conn
is your mysqli connection generated at some point by new mysqli()
it should be:
$result = mysqli_query( $conn,$sql) or die('Could not look up user information; ' . mysqli_error($conn));
The way you were calling it you were passing a string, $sql
as the first argument.
这篇关于警告:mysqli_query()期望参数1为mysqli,字符串为in的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!