<?php
@ $db = new mysqli('localhost:8080','bookorama','bookorama123','books');
if (!$db) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
} $query = "select * from books where isbn like '%31509%'";
$result = $db->query($query); $num_results = $result->num_rows; echo "<p>Number of books found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();
echo "<p><strong>".($i+1).". Title: ";
echo htmlspecialchars(stripslashes($row['title']));
echo "</strong><br />Author: ";
echo stripslashes($row['author']);
echo "<br />ISBN: ";
echo stripslashes($row['isbn']);
echo "<br />Price: ";
echo stripslashes($row['price']);
echo "</p>";
} $result->free();
$db->close();?>
@ $db = new mysqli('localhost:8080','bookorama','bookorama123','books');
if (!$db) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
} $query = "select * from books where isbn like '%31509%'";
$result = $db->query($query); $num_results = $result->num_rows; echo "<p>Number of books found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();
echo "<p><strong>".($i+1).". Title: ";
echo htmlspecialchars(stripslashes($row['title']));
echo "</strong><br />Author: ";
echo stripslashes($row['author']);
echo "<br />ISBN: ";
echo stripslashes($row['isbn']);
echo "<br />Price: ";
echo stripslashes($row['price']);
echo "</p>";
} $result->free();
$db->close();?>
解决方案 »
- 寻找一位PHP+linux方面的前辈
- 关于discuz的问题
- 跪求一个正则表达式!~~~
- php文件出错,但是浏览器不显示错误
- pHP 建站 哪里有好点的模板
- 贡献资源,另外邀请各位加入web设计社区
- 又更新了~调整首页布局和版块排序
- 关闭浏览器,销毁session
- 在windows中如何利用PHP重启httpd
- 数据查询效率好慢 用的thinkphp 11万数据用时0.09
- php-excelreader 只能读取xls php-excelreader怎么不能导入excel2007的.xlsx的文件,报错如下 The filenam
- IIS6.0 重新启动后,Web站点仍然无法访问,需要重启服务器才能回复正常
ini_set("display_errors", 1);//加上这两行,设置PHP报错级别为输出所有错误信息
$db = new mysqli('localhost:8080','bookorama','bookorama123','books'); //去掉@符号,看有没有成功创建数据库连接另外,如果books表的数据量非常大,那按照你写的查询语句就很可能造成PHP执行超时,因为在WHERE子句中的LIKE参数如果以通配符开头的话,就不能使用索引。