mysql - Warning: PDO::__construct() expects at least 1 parameter, 0 given in C:\xampp\htdocs\Svetaine\functions.php on line 43 -
mysql - Warning: PDO::__construct() expects at least 1 parameter, 0 given in C:\xampp\htdocs\Svetaine\functions.php on line 43 -
hello i'm new on pdo , have problem, can somoeone help me?
public function counters() { $dbh = new pdo(); $sql = "select * news order id"; $dbh->query($sql); echo ' <div class="row2"> <h1>svarbios naujienos:</h1> <p></p>'; $count = $c->rowcount(); $s = 0; if($count > 0) { foreach ($dbh->query($sql) $row) { echo ' <p>'.$row['naujiena'].'</p>'; } } echo ' </div> <div class="row2img"> <img src="images/slide2.jpg" width="864" height="210"> </div> '; homecoming 1; }
thanks helping error line $dbh->query($sql);
try this, replace informations database.
public function counters() { $dbh = new pdo("mysql:host=localhost;dbname=dbname", "dbuser", "dbpass"); $sql = "select * news order id"; $dbh->query($sql); echo ' <div class="row2"> <h1>svarbios naujienos:</h1> <p></p>'; $count = $c->rowcount(); $s = 0; if($count > 0) { foreach ($dbh->query($sql) $row) { echo ' <p>'.$row['naujiena'].'</p>'; } } echo ' </div> <div class="row2img"> <img src="images/slide2.jpg" width="864" height="210"> </div> '; homecoming 1; }
php mysql pdo
Comments
Post a Comment