1

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();
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Sagar
  • 45
  • 1
  • 7

1 Answers1

0

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();
}
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85