我收到了这个错误,这让我摸不着头脑:
致命错误:在 /Users/aaronwilson/Desktop/testing_server/ATOM_CMS/functions/sandbox.php:10 中未捕获异常“PDOException”和消息“无效数据源名称”堆栈跟踪:#0 /Users/aaronwilson/Desktop/testing_server/ATOM_CMS /functions/sandbox.php(10): PDO->__construct('SELECT title FR...') #1 /Users/aaronwilson/Desktop/testing_server/ATOM_CMS/config/setup.php(30): get_title(NULL, 'blog') #2 /Users/aaronwilson/Desktop/testing_server/ATOM_CMS/index.php(2): include('/Users/aaronwil...') #3 {main} 在 /Users/aaronwilson/Desktop/ 中抛出testing_server/ATOM_CMS/functions/sandbox.php 第 10 行
这是 sandbox.php 代码:
<?php ## Sandbox PHP/PDO Functions
function get_page($dbc, $pg) {
$sql = new PDO("SELECT * FROM pages WHERE page = '$pg' AND status = 1 LIMIT 1");
$stmt = $dbc->prepare($sql);
$stmt->execute();
$row = $stmt->fetch();
echo '<h1>'.$page['title'].'</h1>';
echo '<div class="content">'.$page['body'].'</div>';}
function get_title($dbc, $pg)
$sql = new PDO("SELECT title FROM pages WHERE page = '$pg' AND status = 1 LIMIT 1");
$stmt = $dbc->prepare($sql);
$stmt->execute();
$row = $stmt->fetch();
return $page['title'];}
?>
在 Setup.php 上有一个 S_GET 函数来拉取 url 以调用 sandbox.php 上的函数:
if ($_GET ['page'] == '') {
$pg = 'home';}
else {
$pg = $_GET ['page']; }