-1

I got an error of :

Call to a member function bind_param() on a non-object

in below code, I have no idea what's wrong, everything seem just fine for me.

$stmt = $db->prepare("INSERT INTO list(title, 
topicDesc,date,kod,country) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param('sssis', 'yo','yo desc','1 may 2015,','123','US');
Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116
aviate wong
  • 745
  • 2
  • 6
  • 10
  • 2
    Your `prepare` failed for some reason (and therefore returned `false`), check the error logs. – CD001 Apr 22 '15 at 15:17
  • @CD001 where to check? I `echo` $db->error it give me nothing? – aviate wong Apr 22 '15 at 15:37
  • Check your DB connection and make sure you're not mixing MySQL APIs, such as PDO. If I had a nickel for everytime I've seen that happen, I'd have 10 bucks worth. Remember to execute your query. Use `if(!$stmt->execute()){trigger_error("there was an error....".$db->error, E_USER_WARNING);}` to catch the error. – Funk Forty Niner Apr 22 '15 at 15:39
  • so, where are we at with this question? comment above make any sense? – Funk Forty Niner Apr 22 '15 at 15:54
  • 1
    you posted this already http://stackoverflow.com/q/29800468/ – Funk Forty Niner Apr 22 '15 at 16:21

2 Answers2

0

$db is not set to an instance of the mysqli class object. This most commonly happens when there is failure in the connection statement. See the mysqli manual page for proper syntax and help debugging errors

MuppetGrinder
  • 234
  • 1
  • 8
0

Try This one It's Working

$stmt = $conn->prepare("INSERT INTO list (title, topicDesc, date,kod,country) 
    VALUES (:title1, :topicDesc1, :date1, :kod1,:country1)");

$stmt->execute(array(
    ':title1' => 'col2',
    ':topicDesc1' => 'col3',
    ':date1' => 'col4', 
    ':kod1' => 'col4', 
    ':country1' => 'col4'));