自分のサイトでの検索に問題があります。このエラーが表示される理由がわかりません
これは私のフォームコードです
<form action="index.php?cat=search_results&learn_id=1" method="post">
<div id="topSearchBodyStyle">
<input type="text" name="search" class="topSearchTextBackground" />
</div>
<div id="topSearchButtonStyle">
<input type="submit" name="submit" class="topSearchButtonBackground" value="" />
</div>
</form>
これはphpコードを含むページです
<?php
$getSearch = $_POST['search'];
trim($getSearch);
if(!get_magic_quotes_gpc()) {
$getSearch = addslashes($getSearch);
}
$connectToDb = "select * from tutorials where tutorial_title like '%.$getSearch.%'";
$searchResults = $db->query($connectToDb) or die($db->error);
if ($searchResults){
$numResultas = $searchResults ->num_rows;
echo "<p>Found : " . $numResultas . "</p>";
while($row = mysqli_fetch_array($searchResults)) {
echo $row['tutorial_title'];
}
}else{
echo "cant connect";
}
?>
「未定義のインデックス:検索」に関するこのメモが表示される理由と、結果が「0」になる理由