RSS
热门关键字:  数据挖掘  人工智能  数据仓库  搜索引擎  数据挖掘导论

在php开发中我遇到这么一个问题,不知道这么解决希望高手多多指导!

来源: 作者: 时间:2008-02-19 点击:

这是浏览网页的时候出现的错误!
Warning:   extract()   [function.extract]:   First   argument   should   be   an   array   in   C:AppServwwwzhuceedit_account.php   on   line   17
以下是我的程序代码:
<?php
if($_POST["op"]   ==   "更         新")   {
include("do_edit_account.inc.php");
exit;
}
session_start();
include("header.inc.php");
include("dbconnect.inc.php");
if($_GET["id"]!=""   &&   $_SESSION["userid"]==1   &&   is_numeric($_GET["id"]))   {
$id   =   $_GET["id"];
}else   {
$id   =   $_SESSION["userid"];
}
$sql   =   "select   *   from   users   where   id='{$id}'";
$res   =   mysql_query($sql);


$row   =   mysql_fetch_array($res);
extract($row);
?>

First       argument       should       be       an       array      
函数第一个参数必须是一个数组.

PHP code
$row = mysql_fetch_array($res); if (is_array($row)){ // or if($row){ extract($row); }else{ die("SQL execute error!"); } ?>
数据挖掘实验室

因为你的查询可能是没有结果的,从而fetch到的$row也是空值。
一般做法是:

PHP code
$result=mysql_query("select * from users where id=$id"); if(@mysql_num_rows($result)){ $row=mysql_fetch_array($result); extract($row); //TODO }

答案出来了吧.

Create By Any-Extract(WL-AE)

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
匿名?