111.php
<?php
/*
mysql*/
class mysql{
private $host;
private $name;
private $pass;
private $database;
private $bm; function __construct($host,$name,$pass,$database,$bm){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->database=$database;
$this->bm=$bm;
$this->connect();
} function connect(){
$link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());
mysql_select_db($this->database,$link) or die("没有该数据库:".$this->database);
mysql_query("SET NAMES '$this->bm'");
}
//------------------------------------------------------------------
//------------------------------------------------------------------
function error(){
return mysql_error();
}
function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('Say:', $sql);
return $query;
}
function show($message = '', $sql = '') {
if(!$sql) echo $message;
else echo $message.'<br>'.$sql;
}
//------------
//------------------------------------------------------------------
//--------------insert-------
function fn_insert($table,$name,$value){
$this->query("insert into $table ($name) value ($value)");
}
//-----delete-------
function fn_delete($table,$idkey,$content){
if($this->query("delete from $table where $idkey='$content'")){
echo "删除成功";
}
}
//-----select-------
function fn_select($ziduan,$biao,$tiaoj){
$this->query("select $ziduan from $biao $tiaoj");
}
}
?>conn.php<?php
include("111.php");
$db =new mysql('localhost','root','root','hjw','gbk');
$select=$db->fn_select('*','shu','');
$row=mysql_fetch_array(mysql_query($select));
while($row){
?>
<table>
<tr>
<td><?php echo $row['fenlei']?></td>
<td><?php echo $row['erji']?></td>
</tr>
</table>
<?php } ?>
总是报错:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\WWW\shu----\conn.php on line 5
<?php
/*
mysql*/
class mysql{
private $host;
private $name;
private $pass;
private $database;
private $bm; function __construct($host,$name,$pass,$database,$bm){
$this->host=$host;
$this->name=$name;
$this->pass=$pass;
$this->database=$database;
$this->bm=$bm;
$this->connect();
} function connect(){
$link=mysql_connect($this->host,$this->name,$this->pass) or die ($this->error());
mysql_select_db($this->database,$link) or die("没有该数据库:".$this->database);
mysql_query("SET NAMES '$this->bm'");
}
//------------------------------------------------------------------
//------------------------------------------------------------------
function error(){
return mysql_error();
}
function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('Say:', $sql);
return $query;
}
function show($message = '', $sql = '') {
if(!$sql) echo $message;
else echo $message.'<br>'.$sql;
}
//------------
//------------------------------------------------------------------
//--------------insert-------
function fn_insert($table,$name,$value){
$this->query("insert into $table ($name) value ($value)");
}
//-----delete-------
function fn_delete($table,$idkey,$content){
if($this->query("delete from $table where $idkey='$content'")){
echo "删除成功";
}
}
//-----select-------
function fn_select($ziduan,$biao,$tiaoj){
$this->query("select $ziduan from $biao $tiaoj");
}
}
?>conn.php<?php
include("111.php");
$db =new mysql('localhost','root','root','hjw','gbk');
$select=$db->fn_select('*','shu','');
$row=mysql_fetch_array(mysql_query($select));
while($row){
?>
<table>
<tr>
<td><?php echo $row['fenlei']?></td>
<td><?php echo $row['erji']?></td>
</tr>
</table>
<?php } ?>
总是报错:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\WWW\shu----\conn.php on line 5
解决方案 »
- PHP中插入声音的问题
- 菜鸟求救,$guestbook =& new Guestbook;
- 带进度条的在线播放器怎么弄?
- 编译php问题
- 如何在网页上实现 eps 格式图片的预览?
- 新的一年,新的开始,一点小分,以表心意!
- 在这里特别感谢鸟儿兄,phpteam兄,秋水无恨以及那些帮助我的兄弟姐妹们...
- 菜鸟问题一:关于phped的:如何实现phped的离线调试功能?
- object 中的id 如何使用,在VBScript中
- 网站一键复制图片功能,复制出来的图片可以粘贴到微信和文档,但是粘贴不到QQ是什么情况
- 求助!在线等!关于PHPexcelreader!
- 怀疑网站域名被劫持..请高手分析一下.
function fn_select($ziduan,$biao,$tiaoj){
return $this->query("select $ziduan from $biao $tiaoj");
}$select=$db->fn_select('*','shu','');
$row=mysql_fetch_array($select);