这种的肯定不是这个db.class.php的错误
看看调试模式是否开启了,没有开启的建议开启就能看到详细的报错信息了
或者贴出你的代码
php
class Db{
public $host;
public $username;
public $password;
public $database;
public $conn;
public $table;
public $sql;
public $field = '*';
function __construct($host,$username,$password,$database){
$this-host = $host;
$this-username = $username;
$this-password = $password;
$this-database = $database;
$this-connect();
}
function connect(){
$this-conn = new mysqli($this-host, $this-username, $this-password,$this-database);
if ($this-conn-connect_error) {
die("连接失败: " . $this-conn-connect_error);
function M($table){
$this-table = $table;
return $this;
function where($array){
$this-sql = '';
$sql = 'where ';
$one = '';
if($array){
if(is_array($array)){
foreach($array as $key=$vo){
$one .= '◆'.$key.'◆ = "'.$vo.'" and';
$one = trim($one,'and');
$sql .= $one;
$this-sql = $sql;
}else{
$sql .= $array;
function add($array){
$sql = 'insert into ◆'.$this-table.'◆ (';
$two = '';
$one .= '◆'.$key.'◆ ,';
$two .= '"'.$vo.'",';
$one = trim($one,',');
$two = trim($two,',');
if($one $two){
$sql .= $one.') values ('.$two.')';
$r = $this-conn-query($this-sql);
if($r){
return mysqli_insert_id($this-conn);
return false;
exit('非数组');
exit('数组为空');
function select(){
$array = '';
$sql = 'select '.$this-field.' from ◆'.$this-table.'◆'.$this-sql;
$result = $this-conn-query($sql);
if ($result-num_rows 0) {
while($row = $result-fetch_assoc()) {
$array[] = $row;
return $array;
function find(){
$row = '';
$sql = 'select '.$this-field.' from ◆'.$this-table.'◆'.$this-sql.'limit 1';
$row = $result-fetch_assoc();
return $row;
function edit($array){
$sql = 'update ◆'.$this-table.'◆ set ';
$one .= '◆'.$key.'◆ = "'.$vo.'",';
$sql .= $one.' '.$this-sql;
$sql .= $array.' '.$this-sql;
$r = $this-conn-query($sql);
return true;
exit('未接收到参数');
function delete(){
$sql = 'delete from ◆'.$this-table.'◆ ';
$sql .= $this-sql;
function order($data){
$this-sql = $this-sql.' order by '.$data;
function limit($data){
$this-sql = $this-sql.' limit '.$data;
function field($data){
$this-field = $data;
$db = new Db('localhost','root','root','database');
①.:用户名密码不对
②.:权限设置的有问题,你可以在 phpmyadmin里,找到用户列表,然后设置权限.
有 Db.class.php ,在实际使用时,还需要 include 文件,而且源代码中要确实定义了 class db.
以上就是土嘎嘎小编为大家整理的关于db.class.php的信息相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!