function del_news($nid)
{
$selnews_str = "select n_class,n_image,n_pname,n_path from news where n_id=".$nid;
$selnews_result = mysql_query($selnews_str,$con);
$selnews_row = mysql_fetch_array($selnews_result);
$class = $selnews_row["n_class"];
if($selnews_row)
{
echo("有内容");
}
else
{
echo("无内容");
}
echo($nid);
}if($_GET["nid"] != null || $_GET["nid"] != "")
{
del_news($_GET["nid"]);
}以上是代码,如果把del_news里的代码放在外面的话就显示有内容,放在函数里调用的话就无内容,参数是正确的。这是什么原因呢?
{
$selnews_str = "select n_class,n_image,n_pname,n_path from news where n_id=".$nid;
$selnews_result = mysql_query($selnews_str,$con);
$selnews_row = mysql_fetch_array($selnews_result);
$class = $selnews_row["n_class"];
if($selnews_row)
{
echo("有内容");
}
else
{
echo("无内容");
}
echo($nid);
}if($_GET["nid"] != null || $_GET["nid"] != "")
{
del_news($_GET["nid"]);
}以上是代码,如果把del_news里的代码放在外面的话就显示有内容,放在函数里调用的话就无内容,参数是正确的。这是什么原因呢?
{
}
$selnews_str = "select n_class,n_image,n_pname,n_path from news where n_id=".$nid;
$selnews_result = mysql_query($selnews_str,$con);
$selnews_row = mysql_fetch_array($selnews_result);
$class = $selnews_row["n_class"];
if($selnews_row)
{
echo("有内容");
}
else
{
echo("无内容");
}
echo($nid);if($_GET["nid"] != null || $_GET["nid"] != "")
{
del_news($_GET["nid"]);
}你的意思是这样就显示内容?
没有错误信息,如果在函数最后加上echo("测试"),可以输出
这里的$conn是局部变量
没有声明Global。
可能是这个原因造成的。
把数据库连接句柄加入函数内部试下。