numaralı telefondan verilir. Web sitem için bir arama özelliği eklemek için bir öğretici takip ediyorum, ancak aşağıdaki hatayı alıyorum:Uyarı: mysqli_num_rows(), mysqli_result parametresinin mysqli_result olması beklenir; boolean, web tasarım ödevimi ile mücadele etmek için
Uyarı: mysqli_num_rows() mysqli_result parametresi 1 olmasını bekler, boolean /search.php içinde verilir hattında 31
hattı 31
<pre>if(mysqli_num_rows($results) >= 1)</pre>
orijinal hata olduğu O (veya idi). yorumlardaki talimatlar uyarınca, o zamandan beri kod revize ettik:
<pre>
<?php
//capture search term and remove spaces at its both ends if the is any
$searchTerm = trim($_GET['keyword']);
//check whether the name parsed is empty
if($searchTerm == "")
{
echo "Enter the name/brand of what you're looking for.";
exit();
}
//database connection info
$host = "localhost";
$db_name = "sookehhh_shopsy_db";
$username = "sookehhh_shopsy";
$password = "xxxx";
//connecting to server and creating link to database
$link = mysqli_connect($host, $username, $password, $db_name) or die('Could not connect: ' . mysqli_connect_error());
//MYSQL search statement
$query = "SELECT * FROM sookehhh_shopsy_db WHERE name LIKE '%" . mysqli_real_escape_string($link, $searchTerm) . "%'";
// original query$query = "SELECT * FROM sookehhh_shopsy_db WHERE name LIKE '%$searchTerm%'";
$results = mysqli_query($link, $query);
//added suggestion below - not sure if correct place?
if (!$result) {
die(mysqli_error($link));
}
/* check whethere there were matching records in the table
by counting the number of results returned */
if(mysqli_num_rows($results) >= 1)
{
$output = "";
while($row = mysqli_fetch_array($results))
{
$output .= "Product Name: " . $row['name'] . "<br />";
$output .= "Price: " . $row['price'] . "<br />";
}
echo $output;
}
else
echo "There was no matching record for that item " . $searchTerm;
?>
</pre>
gerekli değişiklikleri yaptı ve yine güncellendi -
şimdi burada aldığım tek hata mesajı Table 'sookehhh_shopsy_db" dir. sookehhh_shopsy_db 'mevcut değil "
Kullanıcı adını değiştirmem gerektiğini farz ediyorum, belki de çok benzer olduğu için?
Şimdilik yardımlarınız için teşekkürler, ve tüm cehaletim için özür dilerim.
Kendimi öğretmeye çalışıyorum ama maalesef zaman şu an sahip olmadığım bir lüks.
'$ db_name =" shopsy_db; '<- bir kapanış teklifi kaçırdı –
Hrm. Bu sorunu kapatmak için ilgili soru: Kararlar, kararlar ... –
Ayrıca, hem db hem de tablo adı olarak shopsy_db kullanıyorsunuz .. aslında bu durumda ... eğer bu kusmayı yapmadan önce getirme işlemi sorgulama yapılırsa anlamına gelir.Olası yanlış tablo adı? – Orangepill