php入门指南

测试代码:
<html>
<head>
<title>通过PHP连接MySQL服务器</title>
</head>
<body>
<?php
$link = mysqli_connect("127.0.0.1", "root", "123456", "bishe");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$sql = "SELECT * FROM choice_error";
$result = $link->query($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["question_id"]. " - Name: " . $row["question_name"]. " " . $row["question_type"]. "\"\r\n\"";
}
} else {
echo "0 结果";
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
</body>
</html>
Unkonw Unkonw(你不知道一样东西,你也会不知道自己不知道这样东西)

浙公网安备 33010602011771号