代碼不起作用的因素是什麼?執行sql命令
<?php
class mysql
{
var $user;
var $password;
var $database;
var $host;
var $out;
var $query;
function mysql($username, $password, $database, $host, $query)
{
$this->user = $username;
$this->password = $password;
$this->database = $database;
$this->host = $host;
$this->query = $query;
}
function connect()
{
$this->out = mysql_connect($this->host, $this->user, $this->password)
or die("Error cannnot connect to mysql server");
echo "Connected successfully to Mysql server";
mysql_select_db($this->database) or die("Cannot select db");
}
function execution()
{
$re = mysql_query($this->query);
while($row = mysql_fetch_array($re))
echo $row;
}
function out()
{
mysql_close($this->out);
}
}
$connect = new mysql('root','','test','127.0.0.1');
$connect->connect();
$connect->execution('test','SELECT * FROM test');
$connect->out;
?>
更新
$connect = new mysql('root','','test','127.0.0.1','SELECT ss from test');
我已經嘗試上面的代碼及其不要返回任何結果..
SS包含列名ID及其包含的11個值。
請修改您的問題以提供更多信息。此外,您可以在您提出的任何問題的任何答案下使用評論功能。請花些時間閱讀[faq](http://stackoverflow.com/faq)。 – 2011-04-07 18:44:59