1
你好,所以我想爲一個網站whith PDO和PSQL做一個search.php文件,我是種新的所有這一切,所以我得到這個錯誤未知的異常'PDOException'與消息'SQLSTATE [08P01]
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08P01]: <<Unknown error>>: 7 ERROR: bind message supplies 0 parameters, but prepared statement "pdo_stmt_00000001" requires 1' in C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\apache\www\Library\search.php:45 Stack trace: #0 C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\apache\www\Library\search.php(45): PDO->query('SELECT * FROM b...') #1 {main} thrown in C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\apache\www\Library\search.php on line 45
,我不明白爲什麼,我必須做什麼......如果有人可以幫助我 這沒有IDEIA是的search.php文件:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include '/database/dbc.php';
//$sesion_type = $_GET['search'];
$dbc = dbc();
$search = $_POST['q'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Library</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="icon" href="images/biblioteca1.jpg"/>
</head>
<body>
<div id="container">
<div id="header">
<h2>Search</h2>
</div>
<div id="menu">
<ul>
<li><a href="index.php">Home</a></li>
</ul>
<div id="tfheader">
<form id="tfnewsearch" method="get" action="http://localhost:8080/Library/search.php">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
try
{
$quer1 = "SELECT * FROM books WHERE title LIKE :search OR author LIKE :search OR genre LIKE :search OR editor LIKE :search";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
foreach($dbc->query($quer1) as $row)
{
?>
<td><?php echo($row['title']);?></td>
<td><?php echo($row['author']);?></td>
<td><?php echo($row['editor']);?></td>
<td><?php echo($row['price']);?></td>
<td><?php echo($row['genre']);?></td>
<td><?php echo($row['bookid']);?></td>
<?php
}
?>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
它的工作原理!謝謝你:D – Alex 2014-09-21 14:47:51
np,很高興提供幫助 – 2014-09-21 14:48:44