0

I just started to work with bind_param I have a simple HTML form to enter Firstname Lastname and Age into the database however when it is to insert I am getting the call to a member function bind_param() on a non-object error which points to the following line: $stmt->bind_param('ssi',$_POST['$fname'],$_POST['$lname'],$_POST['$age']); below is the insert code: can I please have a few extra pair of eyes to aid

<?php

        $mysqli=@new mysqli('localhost','root','password','test');

        if($mysqli->connect_errno){
            die('Connect Error:'.$mysqli->connect_errno);
        }            

        $stmt=$mysqli->prepare("INSERT INTO tester VALUES (?,?,?)");
        $stmt->bind_param('ssi',$_POST['$fname'],$_POST['$lname'],$_POST['$age']);



        $stmt-> execute();

        printf("%d Row Inserted.\n\n",$stmt->affected_rows);

        $stmt->close();


        $mysqli->close();
    ?>
dames
  • 1,421
  • 8
  • 35
  • 55

1 Answers1

1

Change the following line:

$stmt->bind_param('ssi',$_POST['$fname'],$_POST['$lname'],$_POST['$age']);

to:

$stmt->bind_param('ssi',$_POST['fname'],$_POST['lname'],$_POST['age']);
danmullen
  • 2,556
  • 3
  • 20
  • 28