js传递变量时,php接受不了, HELP !
问个问题 我在js传递变量时,php接受不了, <s...
作者 Hicazm 发布于 2003-09-02 分类:php基础编程
哪里有?
:rolleyes:
逛论坛交流:需要一个mysql操作类
不明白。什么叫操作类呀?
www.pconline.com.cn上见过
要不我给你写一个?
找到了一个,但觉得不太完善。
[PHP]
class DB
{
var $Host =DB_HOST; // 主机名
var $Database =DB_NAME; // 数据库名称
var $User =DB_USER; // 数据库用户
var $Password =DB_PASS; // 数据库用户密码
var $Link_ID = 0; // 连接ID
var $Query_ID = 0; // 查询ID
var $Record = array(); // 查询结果数组
var $Row; // 查询结果记录条数
var $Errno = 0; // 出错标志
var $Error = ""; // 出错标志
function halt($msg)
{
echo("Database error: $msg
");
echo("MySQL error: $this->Errno ($this->Error)
");
die("Session halted.");
}
function connect()
{
if($this->Link_ID == 0)
{
$this->Link_ID = mysql_connect($this->Host, $this->User, $this->Password);
if (!$this->Link_ID)
{
$this->halt("Link_ID == false, connect failed");
}
$SelectResult = mysql_select_db($this->Database, $this->Link_ID);
if(!$SelectResult)
{
$this->Errno = mysql_errno($this->Link_ID);
$this->Error = mysql_error($this->Link_ID);
$this->halt("cannot select database ".$this->Database."");
}
}
}
function query($Query_String)
{
$this->connect();
$this->Query_ID = mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID)
{
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record()
{
$this->Record = mysql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if (!$stat)
{
mysql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
return $this->Record;
}
function num_rows()
{
$Row=mysql_num_rows($this->Query_ID);
return($Row);
}
function close()
{
if($this->Link_ID != 0)
{
mysql_close($this->Link_ID);
}
}
}
[/PHP]
我认为加上一个构建器好一些。
我有,不这个简单,也好用
好,谢谢。收藏先
为什么不用phplib或vbb里的db_mysql.php?
冬冬这个好象也不错,收下了
b cuo
不写用法了..自己应该能看懂...
俺现在觉得phplib里的哪个不好,如果不注意老是出问题,而有的时候就算你知道也不好避免问题,所以俺就不用它了,俺现在用的是中国频道共享平台里的一个db类。。。
9 条回复
回复