mysql query false_mysql_query() 实施结果一直为false
mysql_query() 执行结果一直为false
1)现有一个数据库名为test,里面只有一个表student。
属性名称:ID, Name, Email.
2)尝试着将数据库连接与操作封装成一个类DatabaseManager,并扩展了一个类StudentDetailsDataManager来获取学生信息。
3)问题:能够连接到test数据库,sql语句在数据库中测试过没有问题,但mysql_query()执行sql语句结果一直为false。不知什么问题?
代码如下:
数据库操作基类:DatabaseManager
PHP code//DatabaseManager.php
connection = $connection;
$this->connection = $close_flag;
}
protected function db_open(){
if(empty($this->connection)){
$this->connection = mysql_connect($this->host,$this->user,$this->psw);
if (!$this->connection) {
$this->db_handle_error_connetion();
return false;
}
if (!mysql_select_db($this->name,$this->connection)) {
$this->da_handle_select();
return false;
}
}
}
public function db_close(){
if($this->connection)
mysql_close($this->connection);
}
protected function db_handle_error_connetion(){
echo 'Failed connetion';
}
protected function db_handle_select(){
echo 'Failed access database!';
}
}
?>
------
派生类:StudentDetailsDataManager
PHP code//StudentDetailsDataManager.php
host = "localhost";
$this->user = "root";
$this->psw = "root";
$this->name = "test";
$this->db_open();
}
public function getStudentInfo($ID,&$data){
//$query = "SELECT * FROM student WHERE ID ='$ID'";
$query = "select * from student where ID = '$ID'";
$result = mysql_query($query);
//print_r($result);
if (!$result) {
echo "result is empty!!";
return false;
}
$data = mysql_fetch_array($result,MYSQL_ASSOC);
mysql_free_result($result);
}
}
?>
----
使用StudentDetailsDataManager实例获取学生信息
PHP codegetStudentInfo($ID, $data);
$stuDataManager->db_close();
echo $data["ID"];
?>
------解决方案--------------------
mysql_error看一下就知道了
------解决方案--------------------
public function __construct($connection,$close_flag){
$this->connection = $connection;
$this->connection = $close_flag;
}
这么严重的错误都看不出来?
另外
if (!mysql_select_db($this->name,$this->connection)) {
相关文章
相关视频
mysql query false_mysql_query() 实施结果一直为false相关推荐
- mysql query cache
1.概述: MySQL Query Cache 缓存客户端提交给MySQL的SELECT(注意只是select)语句以及该语句的结果集. 注意:query_cache是mysql server端的查询 ...
- mysql query browswer_MySQL数据库新特性之存储过程入门教程
MySQL数据库新特性之存储过程入门教程 在MySQL 5中,终于引入了存储过程这一新特性,这将大大增强MYSQL的数据库处理能力.在本文中将指导读者快速掌握MySQL 5的存储过程的基本知识,带领用 ...
- mysql query profile_MySQL Query Profile
MySQL Query Profile MySQL 5.0.37 以上开始支持 MySQL Query Profiler, 可以查询到此 SQL 会执行多少时间, 并看出 CPU/Memory 使用量 ...
- mysql query profiler_MySQL Query Profiler
查看MySQL语法详细执行时间与CPU/记忆体使用量: MySQL Query Profiler MySQL的SQL语法调整主要都是使用EXPLAIN,但是这个并没办法知道详细的Ram(Memory) ...
- mysql 查询分析器_mysql查询分析工具|mysql查询分析器(MySQL Query Browser)下载v1.1.20 官方版_ IT猫扑网...
mysql查询分析器又名为mysqlquerybrowser,是一款可以帮助用户快捷进行sql语句查询的工具,让你在编程的过程中更加方便的进行工作.有需要的朋友就来IT猫扑下载吧! MySQL Que ...
- 强大的 mysql管理工具之 Mysql Query Browser
MySQL Query Browser 当启动MySQL Query Browser后,会弹出一个对话框,要求填入你想连接的MySQL服务器的一些基本信息,诸如MySQL服务器的IP地址.端口号.用户 ...
- dz论坛ucenter打不开mysql,Discuz! X3搬家后UCenter出现UCenter info: MySQL Query Error解决方案...
Discuz! X3 X2.5论坛搬家后 登录UCenter出现报错: UCenter info: MySQL Query Error SQL:SELECT value FROM [Table]var ...
- mysql query 优化_第 8 章 MySQL 数据库 Query 的优化
前言: 在之前"影响 MySQL 应用系统性能的相关因素"一章中我们就已经分析过了Query语句对数据库性能的影响非常大,所以本章将专门针对 MySQL 的 Query 语句的优化 ...
- mysql query cache 大小_MySQL查詢緩存:限制為128 MB的最大緩存大小?
My application is very database intensive so I've tried really hard to make sure the application and ...
最新文章
- 2500 字全方面解读 Python 的格式化输出
- wes 7 gost 下载_南京地铁实现移动5G全覆盖下载速度快到飞起_机房360
- JavaWeb黑马旅游网-学习笔记08【旅游线路详情】
- 如何学习 azure_Azure的监督学习
- 微软如何利用机器学习改进Win 10更新体验
- git克隆远程仓库的时候断电了,使用git-fetch断点续传
- 笨办法学 Python · 续 第七部分:大作业
- hive join on 条件 与 where 条件区别
- PL/SQL远程连接Oracle数据库服务器
- 操作系统实验一:并发程序设计
- Bootstrapbutton
- Tableau实战 楼市降温分析(六)现期房销售面积及累计增长
- 打造全功能的NERO
- 光盘镜像和系统启动盘制作
- 【浙大版《C语言程序设计实验与习题指导(第4版)》题目集】实验2-4-4 求简单交错序列前N项和
- vmware:end kernel panic not syncing
- 软件战场加速剧变!诚迈科技成为Elektrobit中国区增值代理经销商
- Centos 7.6 下使用美格SLM750(4G模块)拨号上网
- USB2.0扩展口 SL2.1A芯片
- FX3开发板 及 原理图