未定义的变量!该怎么解决
程序员文章站
2023-12-31 23:54:46
...
未定义的变量!
源代码!
function OpenDB($SQL){
$link = mysql_connect($server_DB, $user_DB, $password_DB)or die("Could not connect:".mysql_error());
mysql_select_db($database_DB, $link);
$result = mysql_query($SQL);
return $result;
}
OpenDB("select * from config WHERE ID = 1");
$row = mysql_fetch_array($result);
echo $row["className"];
错误提示!
Notice: Undefined variable: result in E:\wwwroot\include\config.int.php on line 36
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\wwwroot\include\config.int.php on line 36
------解决方案--------------------
$result=OpenDB("select * from config WHERE ID = 1");
$row = mysql_fetch_array($result);
源代码!
function OpenDB($SQL){
$link = mysql_connect($server_DB, $user_DB, $password_DB)or die("Could not connect:".mysql_error());
mysql_select_db($database_DB, $link);
$result = mysql_query($SQL);
return $result;
}
OpenDB("select * from config WHERE ID = 1");
$row = mysql_fetch_array($result);
echo $row["className"];
错误提示!
Notice: Undefined variable: result in E:\wwwroot\include\config.int.php on line 36
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\wwwroot\include\config.int.php on line 36
------解决方案--------------------
$result=OpenDB("select * from config WHERE ID = 1");
$row = mysql_fetch_array($result);
相关文章
相关视频