<?php
$servername = "localhost";
$username = "root";
$password = "123456";
try {
$conn = new mysqli($servername,$username,$password);
}catch (Exception $e){
die("连接失败:".$e->getMessage());
}
if ($conn->connect_error) {
die("连接失败:".$conn->connect_errror);
}
echo "连接成功";
$sql = "SELECT * FROM u";
$result = $conn->query($sql);
if ($result->num_rows > 0){
echo "$result->num_rows 条结果";
while($row = $result->fetch_assoc()) {
echo "Chromosome Name:" .$row["Chromosome Name"]."Gene ID:".$row["Gene ID"].
"Start Location:".$row["Start Location"]."End Location:".$row["End Location"]."<br>";
}
} else {
echo "0条结果";
}
?>
run code:
[Running] D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.exe "d:\phpstudy_pro\WWW\ceshi.ttt\conn.php"
连接成功0条结果
[Done] exited with code=0 in 0.061 seconds
但是明明表里有结果