Warning: mysqli_query() expects parameter 2 to be string, object given in

后端 未结 2 696
借酒劲吻你
借酒劲吻你 2020-12-07 05:18

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

相关标签:
2条回答
  • 2020-12-07 05:22

    Read the mysqli reference and learn from the error given

    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($con,$query) $query is string and $con is object.

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

    $muestra="SELECT * FROM clientes C INNER JOIN producto P ON C.serial  = P.serial WHERE P.serial = $_GET[serial]";
    
    0 讨论(0)
  • 2020-12-07 05:35

    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);

    0 讨论(0)
提交回复
热议问题