This will be probably stupid problem, but I can't solve it.
I have PDO connection (bdd.php)
<?php
$dbserver="localhost";
$dbuser="root";
$dbpass="";
$dbname="calendar";
$db = new PDO(
"mysql:host=$dbserver;dbname=$dbname;" ,"$dbuser","$dbpass",
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET utf8"
)
);
?>
But I receive this error:
Fatal error: Call to a member function prepare() on a non-object on Index.php on row 6
Here is my "Index.php" :
<?php
require_once('bdd.php');
$sql = "SELECT id, title, start, end, color FROM events ";
$req = $bdd->prepare($sql);
$req->execute();
$events = $req->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
..... (continues is normal HTML / PHP / JS content, not important)