执行到连接数据库那里出错了,但是也不提示错误!
搞不明白具体哪里!
我调试的结果输出到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>
搞不明白具体哪里!
我调试的结果输出到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>
解决方案 »
- 新手求教,关于采集
- PHP domdocument保存的xml的问题。
- gbk_chinese_ci转utf8_general_ci
- svn与bugfree整合问题求助
- 如何把 socket_create获得的resource句柄存储进数据库?
- 请问怎么实现网业上的数据动态实时变化啊?
- 谁有订单系统的程序能否给小弟一份,我MM要做毕设用,谢了!
- win2003+iis6+php4.3.4 isapi模式配置问题。
- PHP如何调用JAVA 类库(转载)
- 一个关于UTF8编码和str_replace函数非常非常奇怪的问题
- 怎么实现在php中修改mysql的存储过程?
- 一种现象:我登陆了msn或者QQ,可以使页面中的QQ图标变亮,即在线状态
把 @ 去掉,看看具体什么错误啊
我去掉了,用DW编辑,然后用遨游浏览,照样不提示任务错误,源代码里只有HTML标签,还缺少
</body></html>我在Zend Development Environment里面调试的时候,居然可以输出结果,怎么回事啊??