无法在PHP中显示sql结果

时间:2013-07-27 15:21:53

标签: php

我可以寻求帮助吗?我试图在SQL Command中运行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);

    }


}

1 个答案:

答案 0 :(得分: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'";
                                                         ^