gpt4 book ai didi

php MySql 白页

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:24 25 4
gpt4 key购买 nike

<分区>

我只是想用 php 做一个简单的事情,但我失败了,不知道为什么。这是我的代码:

<?php

$db_dbname = "name1";
$db_hostname = "hostname";
$db_username = "lol";
$db_password = "thisismypassword";

try
{
$conn = new PDO('mysql:dbname='.$db_dbname.';host='.$db_hostname.'', $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$obterdados = $dbh->prepare("SELECT * FROM tablename ORDER BY id ASC");
$obterdados->execute();
$data= $obterdados->fetchAll();

}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}

?>

在那之后,当我打开页面时,没有执行下面的代码 (html),页面全是白色。如果我删除:

$obterdados = $dbh->prepare("SELECT * FROM tablename ORDER BY id ASC");
$obterdados->execute();
$data= $obterdados->fetchAll();

一切正常

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com