我正在尝试使用 PDO 从 mysql 数据库中检索数据,但“未找到数据库”输出正在执行
这是我的代码
<form id="form" action="sum1.php" method="post">
<td><p align="center"> IDNO : <input type="text" name="id" id="id" maxlength="10"></p></td>
<input type="submit" id="submit" class='btnExample' value="Click here to get your Result">
</form>
<?PHP
$dbhost = "localhost";
$dbname = "demo";
$dbuser = "admin";
$dbpass = "123456";
$db = new PDO("mysql:host=$dbhost;dbname=$dbname", "$dbuser", "$dbpass");
if ($db_found) {
$id = $_POST['id'];
$add = $db->prepare("SELECT htno, SUM(tm) AS tech FROM hmm WHERE htno > :id");
$add -> execute(array('id'=>$id));
echo " <center><table id='mytable' cellspacing='0' border=3 align=center>
<tr><TH scope='col'>Total Marks</TH> </tr><center>";
while ($row1 = $add->fetch(PDO::FETCH_ASSOC))
{
echo "<tr>";
echo "<td align=center>" . $row1['tech4']. "</td>";
echo "</tr>";
}
}
else {
print "Database NOT Found ";
}
$db = null;
?>
我找不到错误
请帮我