-1

我想知道为什么我的PHP/PDO编码在第 9 行和第 16 行收到语法错误。我的代码如下:

<?php
// Sandbox Functions
// PDO example
function get_page($dbc, $pg) {
    $sql = "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 = "SELECT title FROM pages WHERE page = '$pg' AND status = 1 LIMIT 1";
    $stmt = $dbc->prepare($sql);
    $stmt->execute();
    $row = $stmt->fetch()
    return $page['title'];}
?>
4

3 回答 3

0

将 simicolon 放在后面,$stmt->fetch()如下所示: $row = $stmt->fetch();

于 2013-11-08T04:12:27.430 回答
0

缺少分号...

<?php
// Sandbox Functions
// PDO example
function get_page($dbc, $pg) {
    $sql = "SELECT * FROM pages WHERE page = '$pg' AND status = 1 LIMIT 1";
    $stmt = $dbc->prepare($sql);
    $stmt->execute();
    $row = $stmt->fetch(); //missing ;
            echo '<h1>'.$page['title'].'</h1>';
        echo '<div class="content">'.$page['body'].'</div>';}
function get_title($dbc, $pg) {
    $sql = "SELECT title FROM pages WHERE page = '$pg' AND status = 1 LIMIT 1";
    $stmt = $dbc->prepare($sql);
    $stmt->execute();
    $row = $stmt->fetch(); //missing ;
    return $page['title'];}
于 2013-11-08T04:13:11.973 回答
0

您的声明:

$row = $stmt->fetch()

没有分号:

$row = $stmt->fetch();

第 16 行相同:

$row = $stmt->fetch()

$row = $stmt->fetch();
于 2013-11-08T04:13:25.347 回答