致命错误:在第13行的C:\ wamp \ www \ k24Electronics \ admin \ Supplier \ import.php中的非对象上调用成员函数bind_param()

时间:2016-09-23 13:58:13

标签: php php-5.4

function add_product( $product_name, $product_brand, $product_type,
                      $product_description,$product_price, $number, 
                      $reservefee, $status,$image,$supplier_id )

{
     global $data,$sth;
     $con = new mysqli("localhost","root","","eeee");
     $sth = $con->prepare( "INSERT INTO products
                                (product_name,product_brand,product_type,
                                product_description,product_price,number,reservefee,
                                status,image,supplier_id) 
                            VALUES(0,?,?,?,?,?,?,?,?,?,?)" );

     $sth->bind_param('ssssiiisbi', $product_name, $product_brand, $product_type,$product_description,$product_price, $number, $reservefee, $status,$image,$supplier_id);

    $sth->execute();

    $data []= array(
    'product_name' => $product_name,
    'product_brand' => $product_brand,
    'product_type' => $product_type,
    'product_description' => $product_description,
    'product_price' => $product_price,
    'number' => $number,
    'reservefee' => $reservefee,
    'status' => $status,
    'image' => $image,
    'supplier_id' => $supplier_id
    );
}

1 个答案:

答案 0 :(得分:2)

您在$con->prepare中出现错误,因此false已失败,因为它无法处理bind_param对象,因此已返回mysqli_statement

尝试从准备中的VALUES子句中删除?之一,因为您告诉mysql将11个参数插入10个列名称。