$host="43.42.157.14";
$port=3307;
$user="admin";
$password="password";
$dbname="test";
$con = new mysqli($host, $user, $password, $dbname, $port)
or die ('Could not connect to th e database server' . mysqli_connect_error());
if (!$con->connect_error) {
echo "connect successfully"."<br>";
}
$sql = "SELECT * FROM test.calls";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row['id_call'];
}
} else {
echo "0 results";
}
执行此代码后,结果为“连接成功”和“ 0结果”;
在phpmyadmin中,sql查询有效!怎么了?