mysqli_num_rows给出一个布尔错误,但我不明白为什么

时间:2014-06-05 18:13:42

标签: php mysqli boolean

我知道这可能是之前发布的,但我已经对它们进行了审核,它们与我的问题略有不同。它有趣,因为我有这个代码工作,突然它不会工作,但我知道这是因为我升级PHP所以我不知道为什么它现在不工作(顺便说一下,当它工作时它使用" mysql_ "命令但现在使用" mysqli _ "代码)我只需要帮助解决这个问题,它说我给出了一个布尔值,所以我确定我错过了一些但我只是不能看到它。

<?php

//ini_set('display_errors',1); error_reporting(E_ALL | E_STRICT);
$con = mysqli_connect("localhost", "root", "", "Numbers") or die(mysqli_error($con));
//var_dump($_GET);
if(isset($_GET['submit']))
{

$k = $_GET['k'];
?>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<center>
<h2><font size="20">Phone # Database</font></h2>
</center>
<form method="get" action="search.php" >
<table border="0" cellpadding="0" cellspacing="0">
<tr>
    <td>
        <input type="text" name="k" id="text" />
        <input type="submit" name="submit" id="search" value="Search" />
    </td>
</tr>
</table>
<hr />

<?php
$min_length = 1;
if(strlen($k) >= $min_length)
{
$k = htmlspecialchars($k);
$k = mysqli_real_escape_string($con, $k);
echo "<table border='0' width='300' align='center' cellpadding='1' cellspacing='1'>";
echo "<tr align='center' bgcolor='#002C40' style='color:#FFF'> <td height='35px' width='150px'><font size='6'>Phone Number</font></td> </tr>";
$raw_results = mysqli_query($con, "SELECT * FROM numdata WHERE Numb='$k'");
if(mysqli_num_rows($raw_results) > 0)
{
while($results = mysqli_fetch_array($raw_results))
{
echo "<tr align='center' bgcolor='#00FF00'> <td height='25px'><font size='6'>is in database</font></td> </tr>" ;
}
}
else{
echo "<tr align='center' bgcolor='#FF0000'> <td colspan='2' height='25px'><font size='6'>is not in database</font></td> <tr>";
echo "</table>";
}
}
else{
echo "Minimum length is ".$min_length;
}}
?>
</body>
</html> 

0 个答案:

没有答案