0

I get this error:

Fatal error: Call to a member function prepare() on a non-object in /home/folder/public_html/includes/name.php on line 1768  

This is the function:

function _FC_GET($typ, $data, $username){

            global $dbh;
            $stmt = $dbh->prepare("SELECT * FROM stats_clicks WHERE typ=:typ AND user=:username AND data=:data LIMIT 1;");
            $stmt->bindParam(':typ', $typ);
            $stmt->bindParam(':username', $username);
            $stmt->bindParam(':data', $data);
            try {
            $stmt->execute();
            }
            catch(PDOException $e) {
                die( _OP_ERROR($e->getMessage(), __FILE__ ,__LINE__) );     
            }

            $QUERY_DAT = $stmt->fetchAll();
            return empty($QUERY_DAT['value']) ? 0 : $QUERY_DAT['value'];

        }

And this is line 1768:

$stmt = $dbh->prepare("SELECT * FROM stats_clicks WHERE typ=:typ AND user=:username AND data=:data LIMIT 1;");

I can't seem to find what is causing this. I use the $dbh-prepare(); statement in other functions in the same file.

oliverbj
  • 5,771
  • 27
  • 83
  • 178

2 Answers2

0

$dbh is not defined at that line. Check where you create the object $dbh if it is before the line 1768 or it is not in any condition which is not fulfilled.

cibi
  • 16
0

Try this :

Look at here

Probably the cause of your connection.

Community
  • 1
  • 1
Shail Paras
  • 1,125
  • 1
  • 14
  • 34