我會在前言中說我已經堅持了幾天,我明顯是新的,並且知道我錯過了簡單的事情。我嘗試了很多方法。安全性還沒有問題,我只是想在我自己的服務器上學習。檢查數據庫中是否存在值?
即使當我知道該值不存在時,我總能得到'找到的東西'。我試圖在輸入字段中輸入一個短語,按提交併查看錶中的值是否已經存在
對不起,這個愚蠢的問題。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// error_reporting(0);
// ini_set('display_errors', 0);
// exit();
//echo '<pre>'; print_r($user_info); echo '</pre>';
if ((isset($_POST['lookup'])) && ($_REQUEST['lookup'] =='1')) {
echo 'you\'ve entered a keyword, lets see if it exsists!';
$looksql = "SELECT * FROM `crm3`.`keywords` WHERE `KW0` LIKE '".$_POST['lookup']."' ORDER BY `ID` ASC ";
if ($result = mysqli_query($db, $looksql)) {
echo '<br>someting found';
} else { echo '<br>nothing found'; }
} else {
echo '<br>please enter a keyword to start the search';
}
?>
<br><br><br>
<form method="POST" action="./?action=kwcheck">
<input type="hidden" name="lookup" value="1" />
keyword lookup: <input type="text" name="keyword" /><br>
<input type="submit" value="SEARCH" />
謝謝,它現在的作品! –
我仍然得到一個錯誤,因爲我的查詢是錯誤的,它應該是: 'code'的$ _ POST [「關鍵字」]代替$ _ POST [「查找」]'code' 也許我可以藉此一步進一步讓它顯示結果的行ID? –
@DavidWatson是的,你是對的... –