我有以下查询:
$r = "Query goes here...";
$r = conn::execq($q);
while($fetch = mysqli_fetch_array($r)) {
$q = "Query goes here..."; //The $fetch value above is inserted here as 'WHERE' clause
$r = conn::execq($q); //--> The problem
$r = mysqli_fetch_row($r);
if($r > 0) print "ok<br/>";
else print "failed<br/>";
}
在类“ conn ”函数“ execq ”中:
public static function execq($q) {
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error());
$r = mysqli_query($dbc, $q);
mysqli_close($dbc);
return $r;
}
execq函数在一些循环后不会被调用。第一个查询已成功执行,然后正在执行第二个查询。经过一些循环后,查询被停止以调用函数“conn::execq”。有任何想法吗?谢谢..
- - 编辑 - -
conn:openconn(); //Open connection
$r = "Query goes here...";
$r = conn::execq($q);
while($fetch = mysqli_fetch_array($r)) {
$q = "Query goes here..."; //The $fetch value above is inserted here as 'WHERE' clause
$r = conn::execq($q); //--> The problem
$r = mysqli_fetch_row($r);
if($r > 0) print "ok<br/>";
else print "failed<br/>";
}
conn:closeconn(); //Close connection
在类“ conn ”中:
public static function openconn() {
global $dbc;
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error());
}
public static function closeconn() {
mysqli_close($dbc);
}
public static function execq($q) {
$r = mysqli_query($dbc, $q);
return $r;
}
现在我得到了:
Notice: Undefined variable: dbc in ...
Warning: mysqli_error() expects parameter 1 to be mysqli, null given in ...