当我运行时,我得到资源#id 3结果。请查看我的代码并帮我解决这个问题......请
<form method="post" action="search.php" name="search_form" onsubmit="return checkCheckBoxes(this);">
<input type="checkbox" name="search[]" value="qwerty_keypad" id="search1">QWERTY Keypad<br /><br />
<input type="checkbox" name="search[]" value="touch_screen" id="search2"> Touch Screen<br /><br />
<input type="checkbox" name="search[]" value="usb" id="search3">
USB Drive<br /><br />
<input type="checkbox" name="search[]" value="mobile_tracker" id="search4">Mobile Tracker<br /><br />
<input type="checkbox" name="search[]" value="Backup" id="search5">Phone backup on MMC<br /><br />
<input type="submit" value="Search" /> </form>
search.php
<?
$host="localhost"; // Host name
$username="user"; // Mysql username
$password="password"; // Mysql password
$db_name="mydb"; // Database name
$tbl_name="mobile_search"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
foreach($_POST['search'] as $search){
$where[]= "model = '".mysql_real_escape_string($search)."'";
}
$query = "Select model from $tbl_name where ".implode(' OR ',$where);
$result = mysql_query($query);
echo $result;
?>
答案 0 :(得分:4)
这不是mysql结果资源ID的错误。你必须从中获取结果。
while ($row=mysql_fetch_array($result))
{
print_r($row)// will give complete row
}
答案 1 :(得分:1)
阅读本文
mysql_qery()
函数将仅返回资源ID http://php.net/manual/en/function.mysql-query.php
您需要使用mysql_fetch_array
来检索数据