0

is there something wrong with my code, it look exactly like the example on the php page but it give me this error Fatal error: Call to a member function bindParam() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/videosharing/index.php on line 68

$hi = 'hi';
$limit = 4;
$isi = 1;
$query = "SELECT `videoname`,`username`,`videourl`,`uploaddate`,`duration`,`views`,`tags` FROM `videolist` WHERE `tags` = :atagz ";
$stmt = $connection->prepare($query);
$stmt->bindParam(':atagz',$hi);
PM 77-1
  • 12,933
  • 21
  • 68
  • 111
freelixa
  • 111
  • 1
  • 6

1 Answers1

0

Your connection is likely fine (otherwise, you'd have a different error, sooner).

If the error is "Fatal error: Call to a member function bindParam() on a non-object", then $stmt isn't an object. In other words, your prepare() call is failing. Per the documentation for prepare(), that occurs when the database can't prepare the statement.

Reporting these errors is one of the areas where I think PDO falls short. You can get more information on the error with the following:

var_dump($connection->errorInfo());

The most likely cause is a misspelling in an attribute or table name.

alttag
  • 1,163
  • 2
  • 11
  • 29