关于Function函数调用错误问题
我的代码是这样的:/*帐号密码等设定*/
$host = "localhost";
$user = "root";
$pass = "123456";
$database = "ba85d05d ";
//SQL查询B(适合 SELECT 之类)
function sql_b($query)
{
global $host,$user,$pass,$database;
$conn=mysql_connect($host,$user,$pass);
$result=mysql_db_query($database,$query,$conn);
49 mysql_data_seek($result,0);//报错部分
50 while($row=mysql_fetch_row($result))
{
$output[]=$row;
}
mysql_free_result($result);
mysql_close($conn);
return $output;
}
我想通过调用function函数显示一个数组
这个代码是看教程敲出来的,不在怎么会事情老报错,
调用代码:
<?
include("sql.php");//这个sql.php就是上面的代码,就是哪个函数
$sql="select * from liuyan";//这个是张表,里面有些信息。
$data = sql_b($sql);//调用哪个函数
print_r($data);//打印出来,但是就是报错
?>
错误是:
Warning: mysql_data_seek(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\Template\sql.php on line 49
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\Template\sql.php on line 50
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\Template\sql.php on line 54