Quote:
Originally Posted by -Nástý
Code:
$sql = 'SELECT id, title, text, image, alttext, date FROM news WHERE hot = :hot ORDER BY date DESC LIMIT';
$qry = $web->prepare($sql);
$qry->bindValue(':hot', 0);
$qry->execute();
|
Your error is on bindValue. Try this:
[Only registered and activated users can see links. Click Here To Register...]
Code:
$server = "mysql:dbname=DBNAME;host=LOCALHOST";
$user = "root";
$pass = "";
$pdo = new PDO($server,$user,$pass);
$stmt = $pdo->prepare("SELECT id, title, text, image, alttext, date FROM news WHERE hot = :hot ORDER BY date DESC LIMIT");
$stmt->execute([
"hot" => 0
]);
while($dat = $stmt->fetch()){
$id = $dat['id'];
$title = $dat['title'];
$text = $dat['text'];
$img = $dat['image'];
$imgalt = $dat['alttext'];
$date = $dat['date'];
... and so on ...
}
?>
You dont need to bind a value with bindValue(), you can do it with ->execute([ "value" => $value ]);