Reputation: 1389
Here are the binding variables:
$uid = 28;
$csr = 1;
$inr = 1;
$hdr = 1;
$prn = 1;
$pay = 2;
and these are the codes:
$stmt = $mysqli->prepare("INSERT INTO mytable(uid, csr, inr, hdr, prn, pay) VALUES(?,?,?,?,?,?) LIMIT 1");
$stmt->bind_param("iiiiii", $uid, $csr, $inr, $hdr, $prn, $pay);
$stmt->execute();
and this is the error message I am getting:
PHP Fatal error: Call to a member function bind_param() on a non-object
Can anyone spot the mistake here?
Upvotes: 0
Views: 52
Reputation: 2605
The Limit
is used when retrieving data from the query (i.e In a SELECT
). It only receives the limit you set. For more information MySQL Limits
Try this instead, it is without the limit and single quotes (just incase) in bind_param.
$stmt = $mysqli->prepare("INSERT INTO mytable(uid, csr, inr, hdr, prn, pay) VALUES(?,?,?,?,?,?)");
$stmt->bind_param('iiiiii', $uid, $csr, $inr, $hdr, $prn, $pay);
$stmt->execute();
You should also check that your connection is valid.
Reference: http://php.net/manual/en/mysqli-stmt.bind-param.php
Upvotes: 2
Reputation: 587
Remove from your statement this: LIMIT 1
.
It doesn't belong in an "Insert" statement!.
Upvotes: 0