douyou1857 2012-05-03 10:10
浏览 58
已采纳

PDO获取表不起作用

I'm try to use the following script to fetch user data from a table

//if session detected connect to database using pdo
$db = getConnection();

$user = getUser();

//qry the databse
$stmt = $db->prepare("SELECT * FROM saved_holidays WHERE subscriberID = :email");
$stmt->bindParam(":email", $user);


echo "<br></br>
    <table border='2' align='left' width='700'>
    <th align='left'>HolidayID</th>
    <th align='left'>SubscriberID</th>
    <th align='left'>Link</th>
    <th align='left'>Published</th>
    <th align='left'>Title</th>
    <th align='left'>Description</th>
    <th align='left'>Saved</th>
    <br></br>
    <br></br>";

while($obj = $stmt->fetchObject())

{
    echo "<tr><td>".$obj->holidayID."</td><td>".$obj->subcriberID."</td><td>".$obj->link."</td><td>".
    $obj->pubDate."</td><td>".$obj->title ."<td>".$obj->dateSaved."</td><br/>
"."</td></tr>";
}

echo "</table>
    <br></br>
    <br></br>"; 

I don't receive any error messages, but neither do I recieved the desire output. All I get is the table headings, what am doing wrong?

  • 写回答

1条回答 默认 最新

  • dongwaner1367 2012-05-03 10:29
    关注

    Well, you don't execute your query.

    $stmt->execute();
    

    After a query is prepared, and all parameters/values are bound, you need to execute your query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!