php - Not able to store data in table -


this question has answer here:

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 integer
  • d corresponding variable has type double
  • s corresponding variable has type string
  • b corresponding variable blob , sent in packets

reference:


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -