php - Not able to store data in table -
this question has answer here:
- can mix mysql apis in php? 5 answers
not able insert data in table using mysql database
$conn = new mysqli("localhost","username","password", "dbname"); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("insert mail_sent(mid, miid,status) values (:mid, :miid,:status)"); $stmt->bind_param('dds',$mail_id, $inv_id, $mailstatus);//line 37 $stmt->bindparam(':mid', $mail_id); $stmt->bindparam(':miid', $inv_id); $stmt->bindparam(':status', $mailstatus); $stmt->execute();
fatal error: call member function bind_param() on non-object in c:\wamp\www\mail\toinvite.php on line 37
your problem confusing pdo mysqli. pdo have syntax :mid
, mysql/mysqli can't understand this. prepared statements in mysqli, you'll have use ?
placeholders.
if ($stmt = $conn->prepare("insert mail_sent (mid, miid, status) values (?, ?, ?)")) { $stmt->bind_param('iis', $mail_id, $inv_id, $mailstatus); $stmt->execute(); }
as can see, mysqli handles bindings in single line, little different pdo does. also, database has ids ints, assigned them integers in bind_param
(you used doubles).
i
corresponding variable has type integerd
corresponding variable has type doubles
corresponding variable has type stringb
corresponding variable blob , sent in packets
reference:
- http://php.net/manual/en/mysqli-stmt.bind-param.php (mysqli prepared statements)
- http://php.net/manual/en/pdostatement.bindparam.php (pdo prepared statements)
Comments
Post a Comment