• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Fatal error: Call to a member function bind_param()
I've been stuck on this error , please help me this is my code PHP Fatal error: Call to a member function bind_param()

$statement= $db->prepare("insert into uploaddetails(idnum,title,desc,author,tags,title) values(?,?,?,?,?,?)");

     $file= basename($_FILES["fileToUpload"]["name"]);

    $statement->bind_param( 'isssss', $id,$title, $description,$author,$tags,$file);

Since nobody else has spotted the issue, I'll post it for you. The reason you're prepare() is failing is because you're trying to use a MySQL Reserved word. The word desc is a reserved word in MYSQL, which means you need to wrap it in backticks like this:
$statement= $db->prepare("insert into uploaddetails(idnum,title,`desc`,author,tags,file) values(?,?,?,?,?,?)");
It also helps to use proper practice when inserting into a database/using prepared statements.
$statement= $db->prepare("insert into uploaddetails(idnum,title,`desc`,author,tags,title) values(?,?,?,?,?,?)");

if($statement !== FALSE) {
    // do the binds...etc
This shall surely helps you.

Forum Jump:

Users browsing this thread: 1 Guest(s)