我有以下代码:
<?php
$sqla = "SELECT A.sDomain ,valid, invalid FROM ( SELECT SUM(count) AS valid,\n"
. "SUBSTRING_INDEX(REPLACE(REPLACE(REPLACE(ref_url,\'http://\',\'\'),\'https://\',\'\'),\'www.\',\'\'),\'/\',1) AS sDomain \n"
. "FROM ref_records WHERE user_id = 6969 GROUP BY sDomain ORDER BY 1 DESC) as A\n"
. "INNER JOIN\n"
. "( SELECT SUM(invalid) AS invalid,\n"
. "SUBSTRING_INDEX(REPLACE(REPLACE(REPLACE(ref_url,\'http://\',\'\'),\'https://\',\'\'),\'www.\',\'\'),\'/\',1) AS sDomain\n"
. "FROM ref_records WHERE user_id = 6969 GROUP BY sDomain ORDER BY 1 DESC) as B\n"
. "on A.sDomain=B.sDomain";
$resulta = mysqli_query($con, $sqla);
while($recorda = mysqli_fetch_array($resulta)) {
echo '<tr class="btn-group btn-group-justified default">
<td>' . $recorda['sDomain'] . '</td>
<td><span class="text-danger">' . number_format($recorda['valid']) . '</span></td>
<td>' . number_format($recorda['invalid']) . '</td></tr> ';
}
mysqli_close($con);
?>
SQL查询在phpMyadmin中工作得很好,并返回一个包含3列的表:sDomain,valid&amp;无效。但是,当我尝试从该查询构建一个html表时,它会抛出以下错误:
[15:29:26] PHP Warning: mysqli_query(): Couldn't fetch mysqli in test.php on line 203
[15:29:26] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in test.php on line 205
[15:29:26] PHP Warning: mysqli_close(): Couldn't fetch mysqli in test.php on line 216
猜猜我在这里错过了什么......