0

I have some code that works (mysqli), but I need to make it secure from SQL injection:

$sql = "INSERT INTO scratch_entry (email, fname, lname, phone, promo) VALUES ('$email', '$fname', '$lname', '$phone', $promo);";

I attempted to use a prepared statement, but I keep getting the error Fatal error: Call to a member function bind_param() on a non-object

This is what I am attempting to use and is giving me the error:

$stmt = $mysqli->prepare("INSERT INTO scratch_entry (email, fname, lname, phone, promo) VALUES(:email, :fname, :lname, :phone, :promo");
$stmt->bind_param(":email", $email);
$stmt->bind_param(":fname", $fname);
$stmt->bind_param(":lname", $lname);
$stmt->bind_param(":phone", $phone);
$stmt->bind_param(":promo", $promo);
$stmt->execute();

Does anyone know what I am doing wrong with this prepared statement? If you need more info let me know. Thanks!

Cliff
  • 57
  • 7

0 Answers0