PHP准备。 Stmt - 出了什么问题?

I'm trying to learn PHP with prepared statements and I have had some frustrating errors before but I figured them out by myself ( after 4 frustrating hours ). Now i'm getting this error : Fatal error: Call to a member function bind_param() on a non-object in .... on line 15.

<?php
$host="127.0.0.1";
$port=3306;
$socket="";
$user="root";
$password="";
$dbname="ewt";

$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());

$mysqli = $con;

$stmt = $mysqli->prepare("INSERT INTO PERSOON VALUES (?,?,?,?,?,?,?,?)");
$stmt->bind_param('ssssssid',$firstName,$lastName,$email,$pass,$address,$city,$zip,$telephone);

$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$telephone = $_POST['telephone'];

$stmt->execute();
$stmt->close();
$mysqli->close();

I have absolutely no idea what's wrong with the code.

I spy two possible problems, and one irrelevant but important problem that will immediately bite you as soon as you fix the possible problems.

  1. I doubt your table name is PERSOON. PERSON, maybe.
  2. I also doubt your table has exactly eight columns. Or if it does, you don't have an ID column which is a really bad idea to be missing.

In either of these cases, your prepare() call will return false, which is obviously not an object. You would be able to determine the exact error using var_dump($mysqli->error);

And the important problem: You are attempting to use all your extracted $_POST variables before you declare them...