这里公司名称的总行数是100000,但得到的错误就像 服务器无法处理请求。
<?php
$servername="localhost";
$username="root";
$password="";
$dbname="ABC";
$conn = mysqli_connect($servername, $username, $password, $dbname );
if($conn){
$result = mysqli_query($conn, " SELECT COMPANY_NAME from mytask "));
$emparray = array();
while($row = mysqli_fetch_assoc($result))
{
$emparray[] = $row;
}
var_dump($emparray);
exit;
}
else{
echo "Connection Not Successful";
}
?>
答案 0 :(得分:-1)
你有一个拼写错误,一个额外的括号。更改以下行:
$result = mysqli_query($conn, " SELECT COMPANY_NAME from mytask "));
到这一行:
$result = mysqli_query($conn, " SELECT COMPANY_NAME from mytask ");
<强>编辑:强> 另外,请更改以下代码:
while($row = mysqli_fetch_assoc($result))
{
$emparray[] = $row;
}
var_dump($emparray);
进入此代码:
while($row = mysqli_fetch_assoc($result))
{
foreach ($row as $value)
{
echo "--".$value;
}
echo "<br>";
}
让我知道它现在是否有效。
答案 1 :(得分:-1)
你可以尝试:
$mysqli = new mysqli($servername,$username,$password,$dbname);
$stmt = $mysqli->prepare("SELECT COMPANY_NAME FROM mytask");
$sql = stmt->execute();
while ($row = $sql->fetch_object()) {
$emparray[] = $row->COMPANY_NAME;
}
var_dump($emparray);
exit;