-3

我正在尝试将数据库行插入到对象中,但我不明白这里有什么问题:(我看不到输出)。

<body>
<?php header('Content-Type: text/html; charset=utf-8');
include("dash_class.php");
mysql_connect("localhost", "root", "") or
    die("Could not connect: " . mysql_error());
mysql_select_db("msordash");
mysql_query("SET NAMES 'utf8'");
$dashim=mysql_query("SELECT * FROM dash");

while ($row = mysql_fetch_array($dashim)) { 
    $dash=new dash($row["name"],$row["msg"],$row["msg_date"]);

    echo $dash->name;
}
?>

</body>

类代码:

class dash
{
public $name;
public $msg;
public $msg_date;

function __constractor($name,$msg,$msg_date){
$this->name=$name;
$this->msg=$msg;
$this->msg_date=$msg_date;}


}

?>
4

1 回答 1

0

什么是 constraaaaaaaaaactor?:) 对不起,constractor准确的说是什么?

function __constractor($name,$msg,$msg_date){

它应该是

__construct()

function __construct($name,$msg,$msg_date){
于 2013-03-27T17:09:25.630 回答