0

我可以寻求帮助吗?我尝试在SQL命令中运行sql,运行成功,但是运行php文件时无法显示结果,代码有问题吗?谢谢你。

    define('DB_HOST', 'localhost');
    define('DB_USER', 'root');
    define('DB_PASS', '');
    define('DB_NAME', 'steakhouse');

    $con = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

   $sql1 ="SELECT r.MemberId,m.MFirstName,m.MLastName,m.MEmail,r.SeatAmount
             FROM member m,reservation r
             where m.MemberId=r.MemberId AND r.SeatAmount>=10'";


if ($result1 = $con->query($sql1))
{  
    while ($row1 = $result1->fetch_object())
    {
        printf('<tr><td align="center">%s</td>
            <td align="center">%s %s</td>
            <td align="center">%s</td>
            <td align="center">%d</td> </tr> ',

                $row1->MemberId,
                $row1->MFirstName,
                $row1->MLastName,
                $row1->MEmail,
                $row1->SeatAmount);

    }


}
4

1 回答 1

0

您确定 SQL 查询末尾的单引号不会导致异常吗?

$sql1 ="SELECT r.MemberId,m.MFirstName,m.MLastName,m.MEmail,r.SeatAmount
         FROM member m,reservation r
         where m.MemberId=r.MemberId AND r.SeatAmount>=10'";
                                                         ^
于 2013-07-27T15:24:17.193 回答