简体   繁体   中英

Getting Error while using PHP Prepared Statement for Insert “Call to a member function bind_param() on a non-object”

I'm using php prepared statement to insert into mysql database, but I'm getting:

Call to a member function bind_param() on a non-object

while trying to insert, I tried in Google and everywhere else, but I am still stuck!

$loc=$_POST['location'];
$name=$_POST['name'];
$chname=$_POST['chname'];
$address=$_POST['address'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$plan=$_POST['plan'];

$stmt = $con->prepare("INSERT INTO clinic_registration (location, clinic_name, chief_doctor,clinic_address,clinic_phone,clinic_email,clinic_plan,clinic_username,clinic_password) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");

$stmt->bind_param("ssssisiss",$loc,$name,$chname,$address,$phone,$email,$plan,$name,$name);

$stmt->execute();

check the connection

<?php
$con= new mysqli('localhost', 'my_user', 'my_password', 'world');

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM