执行到连接数据库那里出错了,但是也不提示错误!
搞不明白具体哪里!
我调试的结果输出到0,1后就没有输出了!
怎么回事呢?本地有名为knife_app的数据库,用户名knife 密码123456
用PHPMYADMIN可以链接管理!代码如下
<?php
$searchtype = $_POST["searchtype"];
$searchterm = trim($_POST["searchterm"]);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>搜索结果</title>
</head><body>
<?php
if (!$searchtype || !$searchterm)
{
echo "请返回填写完整的搜索信息再重试!";
exit;
}
echo "0";
if (!get_magic_quotes_gpc())
{
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
}
echo "1";
@ $db = new mysqli('localhost','knife','123456','knife_app');
echo "2";
if (mysqli_connect_errno())
{
echo "未能连接上数据库,请稍候重试!";
exit;
}
echo "3";
$query = "select * from books where ".$searchtype." like '%".$searchterm."%'";
echo $query;
$result = $db->query($query);
$num_results = $result->num_rows;
echo "Number of books found:$num_results";
for ($i=0;$i<$num_results;$i++)
{
$row = $result->fetch_assoc();
echo ($i+1)."Title";
echo htmlspecialchars(stripslashes($row["title"]));
echo "<br />Author:";
echo stripslashes($row["author"]);
echo "<br />ISBN:";
echo stripslashes($row["isbn"]);
echo "<br />Price:";
echo stripslashes($row["price"]);
}
$result->free();
$db->close();
?>
</body>
</html>

解决方案 »

  1.   

    @ $db = new mysqli('localhost','knife','123456','knife_app');
    把 @ 去掉,看看具体什么错误啊
      

  2.   


    我去掉了,用DW编辑,然后用遨游浏览,照样不提示任务错误,源代码里只有HTML标签,还缺少
    </body></html>我在Zend Development Environment里面调试的时候,居然可以输出结果,怎么回事啊??
      

  3.   

    用zend studio调试跟你服务器的web环境是不一样的,也就是说很多环境变量和一些权限是不一样的,得细心比较