我有一个简单的SQL查询,如果我包含ID字段,则根本无法使用。 说明:如果我删除对ID的引用,不更改max_connections或其他任何内容,则代码将运行。
如果我说WHERE CustomerProfile.ID or SponsorID
,则不起作用。
如果我自己说CustomerProfile.ID
,那是行不通的。
仅当我说SponsorID
时才有效。
ID
和SponsorID
字段均为INT(11)
。 ID
是AutoIncrement
。两者都将Null
设置为No
。 SponsorID
默认为0
代码:-
<?php
function fdownline($selectedcustomerid){
if (empty($selectedcustomerid)){
exit;
}
include ('incconn.php');//this only contains database, host, user and password
mysqli_close($dbconnection);
$dbconnection = mysqli_connect($dbhost,$dbusername,$dbpassword,$database) or die (mysqli_error());
global $biglist;
$myquery = "SELECT * FROM CustomerProfile WHERE CustomerProfile.SponsorID = $selectedcustomerid";// this works
//$myquery = "SELECT * FROM CustomerProfile WHERE CustomerProfile.ID = $selectedcustomerid OR CustomerProfile.SponsorID = $selectedcustomerid";//Does not work
//$myquery = "SELECT * FROM CustomerProfile WHERE CustomerProfile.ID = $selectedcustomerid";//Does not work
$result = mysqli_query($dbconnection, $myquery) or die (mysqli_error($dbconnection));
if (mysqli_num_rows($result)>0){
while ($myrow = mysqli_fetch_array($result)){
$customerid = $myrow['ID'];
$biglist[$customerid] = $myrow;
fdownline($customerid);
}
}
// close connection
mysqli_close($dbconnection);
}
?>
结果页面来源错误:
mysqli_connect()[function.mysqli-connect]: (08004/1040):连接过多