-1

I booted up wamp today to check something for one of my website and ran across a php error

[30-Jan-2022 16:57:28 UTC] PHP Fatal error:  Uncaught Error: Call to a member function prepare() on boolean in C:\wamp64\www\includes\class.database.php:130
Stack trace:

When checking the php file in question i have no idea how to fix this, anyone that can help?

// Allow for prepared arguments. Example:
// query("SELECT * FROM table WHERE id = :id", array('id' => $some_val));
$sth = $this->db->prepare($sql);
$debugSql = $sql;
$params = array();
if (is_array($args_to_prepare))
{
    foreach ($args_to_prepare AS $name => $val)
    {
        $params[':' . $name] = $val;
        $debugSql = preg_replace('/:'.$name.'/',"'".$val."'", $debugSql);
    }
}

1 Answers1

-1

The best way to reuse functions is to put it inside of the include file, then include it at the top of each file you'll need it. So inside of your db_connection.php, create your function:

Click this

  • The problem is because there is no database connection. Are you sure you checked? Where is the connect function? Is it included in the page? – ulusanyazilim Jan 30 '22 at 22:24
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 31 '22 at 07:57