我是一名php新手,我試圖讓這個表單正常工作,但是當我運行我的查詢時,我得到一個「錯誤獲取數據」。 對此的任何幫助將是太棒了!獲取數據出錯 - 從數據庫檢索數據php
下面是HTML表單代碼:
<html>
<head>
<title>Where to go play basketball?</title>
<style type="test/css">
table {
background-color: #FCF;
}
th {
width:150px;
text-align:left;
}
</style>
</head>
<body>
<h1>Venue Search</h1>
<form method="post" action="search.php">
<label> Search Criteria: <input type="text" name="term" /></label>
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
這裏是search.php中:
<?php
mysql_connect ("localhost", "root","*****", "baskt_venues") or die (mysql_error());
$term = $_POST['term'];
$sql = mysql_query("SELECT * FROM complete_table WHERE country LIKE $term")or die('error getting data');
while ($row = mysql_fetch_array($sql, MYSQLI_ASSOC)){
echo '<br/> Country: '.$row['country'];
echo '<br/> Date: '.$row['date'];
echo '<br/> Time: '.$row['time'];
echo '<br/><br/>';
}
?>
感謝大家花時間來看看這個。
甚至當我更換,我得到「錯誤獲取數據」 :( – 2013-03-06 15:37:25
的SQL現在看來很好,但我們需要在錯誤的詳細信息請嘗試更換。 ''或死('錯誤獲取數據')''用'或死(mysql_error())'來判斷實際的錯誤是什麼 – jlundqvist 2013-03-06 15:43:02
jlundqvist,@zukanta,非常感謝你的幫助,現在有效。 (「localhost」,「root」,「password」,「wcs_venues」)或者die(mysql_error())。這是一個非常有用的幫助!我真的很感激它! – 2013-03-06 16:17:00