急!请高人指点一下,这段代码错在哪里,应该怎样改正!多谢!

class instance{

private static $mysqli;

public $username="root";/*数据库用户名*/

public $passwd="root";/*数据库密码*/

static function create_mysqli(){

if (!self::$mysqli){

self::$mysqli= new mysqli($this->username,$this->passwd,"caocao");

}/*if循环结束*/

return self::$mysqli;

}/*create_mysqli()函数结束*/


}/*类结束*/

class display_content{

private $sql;/*传入的SQL语句用于获得总共的记录*/

private $page_size;/*每页显示多少条*/

private $comment_page_size;/*每条显示多少评论*/

private $show_comment;/*是否显示评论true或者false*/

private $pages;/*总页数*/

private $current_page;/*当前页数*/

private $conn;/*数据库连接句柄*/

function __construct($sql,$page_size,$comment_page_size,$show_comment){/*赋值*/

$this->sql=$sql;

$this->page_size=$page_size;

$this->comment_page_size=$comment_page_size;

$this->show_comment=$show_comment;

$this->conn=instance::create_mysqli();

}

function get_pages(){/*获得总页数*/

$result=$this->conn->query($this->sql);

$num=$result->num_rows;

if ($num%$this->page_size!=0){

$pages=($num/$this->page_size)+1;

}else {

$pages=$num/$this->page_size;

}

$this->pages=$pages;

return $this->pages;

}/*函数结束*/

 
function get_array(){/*获得查询得到的数组*/

$this->conn->query("set names 'utf8'");

if ($this->current_page<=$this->pages){

$current_page=$this->current_page;

}else {

$current_page=$this->pages;

}/*判断所得当前页是否超过总页数*/

$query=$this->sql."limit 0 ,".$current_page."order by ID DESC";

$result=$this->conn->query($query);

while ($row=$result->fetch_assoc()){

if ($this->show_comment==true){

$this->conn->query("set names 'utf8'");

$query2="select * from caocao_comment where main_channel_ID=1 and second_channel_ID=".$row['ID']."limit 0 ,".$this->comment_page_size."order by ID DESC";

$result2=$this->conn->query($query2);

while ($row2=$result2->fetch_assoc()){

$comment[]=array('comment_id'=>$row2['ID'],'comment_date'=>$row2['date'],'comment_time'=>$row2['time'],'comment_content'=>$row2['content']);

}/*循环显示评论*/

unset($comment);

$row['comment']=$comment;

$array=array('arry'=>$row);

return $array;

}/*如果需要显示评论*/else {

$array=array('array'=>$row);

}/*如果不需要显示评论*/

}/*外部项目循环*/


}/*函数get_array()结束*/

function __destruct(){/*注销数据库连接*/

$this->conn->close();

}

}/*类结束*/


在此,先谢谢大家了!

作者: PainsOnline   发布时间: 2011-05-19

错在哪里PHP会告诉你,把错误信息发上来,拜托。

作者: T5500   发布时间: 2011-05-19

看看错误信息先~

作者: zhukai1   发布时间: 2011-05-19