警告:mysqli_query()希望参数2为string,对象为in。

时间:2022-11-23 14:15:19

Good morning!

早上好!

I'm new in PHP. i'm trying to make work this scrpt but is showing me this problem. It's a forma that modifies some records in a mysql database. The codes gets the data but it shows me that mistake and when i run modify it shows me several problems....

我刚在PHP。我正在努力把工作搞得一团糟,但却给我展示了这个问题。它是在mysql数据库中修改一些记录的形式。代码获取数据,但它显示了我的错误,当我运行修改它向我展示了几个问题....

Warning: mysqli_query() expects parameter 2 to be string, object given in C:\wamp\www\CTE\formedicion.php on line 15

警告:mysqli_query()期望参数2为string,对象为C:\wamp\www\CTE\formedicion。php在第15行

I still don't know how to fix it. I really appreaciate your help.

我还是不知道怎么修理。我非常感谢你的帮助。

Thanks!

谢谢!

<body>

<?php

include "conexiondb.php";

if(!isset($_POST['submit'])){

//$busqueda=$con->query(    
$muestra=$con->query("SELECT * FROM clientes C INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]");

//mysqli_query($con,$sql);  
mysqli_query($con,$muestra);

$person=$muestra->fetch_array();
}
?>

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">

  cliente<input type = "text" name="inputcliente" value = "<?php echo $person['cliente']; ?>" /><br/>

  cedula <input type = "text" name="inputcedula" value = "<?php echo $person['cedula']; ?>" /><br/>

<input type="hidden" name="serial" value="<?php echo $_GET['serial'];?>"/>
<input type = "submit" name = "submit" value= "Modificar"/>
</form>

  <?php
  if (isset($_POST ['submit'])){

$u = "UPDATE cliente SET'cliente'='$_POST[inputcliente]','cedula' = '$_POST[inputcedula]' WHERE serial=$_POST[serial]";
mysqli_query($con,$u);

echo "El usuario ha sido modificado";
header ("Location:busca.php");

} else {

      }

  ?>
</body>
</html>

2 个解决方案

#1


1  

Change

改变

$muestra=$con->query("SELECT * FROM clientes C 
INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]");

To

// Updated to clean the input

//更新后清洗输入。

$serial = mysqli_real_escape_string($con,$_GET[serial]) ;

$qry="SELECT * FROM clientes C 
INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $serial";

Then

然后

$muestra = mysqli_query($con,$qry);

具体美元= mysqli_query(案子,qry美元);

#2


0  

Read the mysqli reference and learn from the error given

读取mysqli引用并从所给出的错误中学习。

your error is that mysqli_query expects seconnd parameter to be a string but you are not giving a string variable as the argument.

您的错误是,mysqli_query期望第二个参数是一个字符串,但是您没有给出一个字符串变量作为参数。

mysqli_query($con,$query) $query is string and $con is object.

mysqli_query($con,$query) $query是字符串,$ con是对象。

Your solution is to make $muestra to be a string.

您的解决方案是让$muestra成为一个字符串。

$muestra="SELECT * FROM clientes C INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]";

#1


1  

Change

改变

$muestra=$con->query("SELECT * FROM clientes C 
INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]");

To

// Updated to clean the input

//更新后清洗输入。

$serial = mysqli_real_escape_string($con,$_GET[serial]) ;

$qry="SELECT * FROM clientes C 
INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $serial";

Then

然后

$muestra = mysqli_query($con,$qry);

具体美元= mysqli_query(案子,qry美元);

#2


0  

Read the mysqli reference and learn from the error given

读取mysqli引用并从所给出的错误中学习。

your error is that mysqli_query expects seconnd parameter to be a string but you are not giving a string variable as the argument.

您的错误是,mysqli_query期望第二个参数是一个字符串,但是您没有给出一个字符串变量作为参数。

mysqli_query($con,$query) $query is string and $con is object.

mysqli_query($con,$query) $query是字符串,$ con是对象。

Your solution is to make $muestra to be a string.

您的解决方案是让$muestra成为一个字符串。

$muestra="SELECT * FROM clientes C INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]";