TopDollarUK
TopDollarUK

Reputation: 47

MYSQLi prepared insert not working..

I am stuck on mysqli prepare.. and I am all but certain there isn't a mistake in the prepared statement. Yet im getting the "call to non-member object error".. from what I recall this error only occurs if infact there is an error with the statement.." Call to a member function bind_param() on a non-object ".. I'm not too sure if I have used any reserved words.. Maybe someone can help..

$stmt = $mysqli->prepare("INSERT INTO customers (cid, company, fname, sname, email,  mobile, email_notif, sms_notif, telephone, address, postcode, city, town, allowedLogin, date, addedby)
                          VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

$stmt->bind_param("ssssssssssssssss", $id, $company, $fname, $sname, $email, $mobile, $emailnotif, $smsnotif, $telephone, $address, $postcode, $city, $town, $allowedLogin, $date, $addedby);

    if( $stmt->execute() )
    {   
        /* Free Result Set */
        $stmt->close();
        return true;    
    } 
   else
   {
        return "<p>".$mysqli->error."</p>";
   }

p.s I am passing the variables via a function call:

addCustomer($company,$fname,$sname,$email,$mobile,$smsnotif,$emailnotif,$telephone,$address,$postcode,$city,$town,$allowedLogin, $date, $addedby);

Upvotes: 1

Views: 883

Answers (2)

SeanWM
SeanWM

Reputation: 16989

date is a reserved word. Try adding backticks around it.

Upvotes: 1

Travis G
Travis G

Reputation: 1602

i see $id being in bind_param used but not passed from the function addCustomer

Upvotes: 0

Related Questions