Connection failed: SQLSTATE[28000] [1045] Access denied for user 'rkcat'@'localhost' (using password: YES) Fatal error: Call to a member function query() on a non-object in
<?php
$servername = "localhost";
$username = "rkcat";
$password = "rkcat123!@#";
enter code here
try {
$conn = new PDO("mysql:host=$servername;dbname=shradha_padma", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
$sql = "SELECT * FROM slider";
$result = $conn->query($sql);
$data = $result->fetchAll(PDO::FETCH_ASSOC);
?>