doucou19961205 2015-08-09 11:27
浏览 65

显示聊天消息时出错

i'm trying to create a chatroom as an exercise, my code has a weird behavior: (PS: running with wampserver)

<?php
    header('Content-Type: application/x-www-form-urlencoded');
    try{
        $pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
        $bdd = new PDO('mysql:host=localhost;dbname=test','root','',$pdo_options);
        $msg = $bdd -> query('SELECT * FROM chatroom ORDER BY heure LIMIT 0,10');
        while($current = $msg->fetch()){
?>
            <div class='messages' ><?php echo $current['id']; ?></div><br/>
<?php
        }
        $msg->closeCursor();
    }
    catch(Exception $e){
        die('Erreur:'.$e->getMessage());
    }
?>

and I get this:

query('SELECT * FROM chatroom ORDER BY heure LIMIT 0,10'); while($current = $msg->fetch()){ ?>

closeCursor(); } catch(Exception $e){ die('Erreur:'.$e->getMessage()); } ?>

Where am I wrong? There must be a syntax error somewhere but I don't find it.

  • 写回答

1条回答 默认 最新

  • dsns47611 2015-08-09 12:16
    关注

    I don't know why , but I was saving the file as an html page(dit it before , no problem) and I saved it as php file and now it works.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?