When I try to run the SELECT
on the server it accuses this msg: Fatal error: Call to a member function prepare() on a non-object in blog.php on line 97
the line referred to is this:
$readPost = $db->prepare($postagemRead);
A little more like this:
$pg = 1;
$limite = 5;
$inicio = ($pg * $limite) - $limite;
$postagemRead = "SELECT * FROM postagem ORDER BY datapost DESC LIMIT :inicio,:limite";
try{
$readPost = $db->prepare($postagemRead);
the connection file is this:
<?php
try{
$db = new PDO("mysql:dbname=database;host=localhost;charset=utf8;","root","");
}catch(PDOException $e){
$e -> getMessage();
}
?>
I do not see the problem seen running this on the local server (wamp server) and running normal, but on the host of this error what can it be?
Error:
exception 'PDOException' with message 'SQLSTATE [28000] [1045] Access denied for user 'root' @ 'localhost' (using password: NO) 'in /home/vhosts/molbe.freetzi.com/config.php:3 Stack trace: # 0 /home/vhosts/molbe.freetzi.com/config.php(3): PDO- > __ construct ('mysql: dbname = 85 ...', 'root', '') # 1 /home/vhosts/molbe.freetzi.com/padrao.php(1): require_once ('/ home / vhosts / mo ...') # 2 {main} 'in /home/vhosts/molbe.freetzi.com/config.php:5 Stack trace: # 0 /home/vhosts/molbe.freetzi.com/padrao.php(1): require_once () # 1 {main} thrown in /home/vhosts/molbe.freetzi.com/config.php on line 5