I am getting Call to a member function query() on a non-object in G:\PleskVhosts\angelsoftweb.com\angelunitrax.angelsoftweb.com\header.php on line 116
db.php
<?php
$servername = "########";
$username = "########";
$password = "########";
$dbh = "rfid";
try {
$conn = new PDO('mysql:host=localhost;dbname=$dbh', $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
?>
header.php
<?php
foreach($sql=$conn->query("SELECT * FROM header_section") as $st) {
echo'
<div class="col-sm-2 col-md-2">
<ul style="margin-top: 13px;">
<li><a href="callus.php"><span style="margin-left:5px; color:white;
font-size:16px; font-weight:bold;"><b>'.$st['call_us_name'].'</b></span>
<span style="margin-left:5px; color:white; font-size:16px;
font-weight:bold;">'.$st['number'].'</span></a></li>
</ul>
</div>';
}
?>
I tried to solve this but not got what is the problem van some one help me with this to solve this as soon as possible...