doumi9618 2011-12-15 17:08
浏览 19

更改数据库中的标志以显示某人“在线”,但它无法正常工作

Here is a little breakdown of whats going on

The biggest problem I have right now is, in login.php, it is supposed to change a flag in the database to show a person is online.

if($table=='chatmodels'){
              $sql="update ".$table." set loginStatus=1 where user=".$id['user'];
$upd=mysql_query($sql);

It should change 'chatmodels.loginStatus' to equal 1 once a person successfully logs in, but it doesn't work. It used to work.

I'm pretty sure the I have something wrong in the database configuration.

Here is a screenshot of my database http://i.stack.imgur.com/BcaII.jpg

  • 写回答

2条回答 默认 最新

  • duanhuan3705 2011-12-15 17:26
    关注

    From the screen shot, I see that the chatmodels table resides in the qoc1 database.

    Since you are using php, you need to do one of two things:

    Option 1 : Use mysql_select_db as follows:

    mysql_select_db('qoc1'); before calling for the update query

    if($table=='chatmodels'){ 
              mysql_select_db('qoc1');
              $sql="update ".$table." set loginStatus=1 where user=".$id['user']; 
    $upd=mysql_query($sql); 
    

    Option 2 : Put qoc1 into the query itself:

    if($table=='chatmodels'){ 
              $sql="update qoc1.".$table." set loginStatus=1 where user=".$id['user']; 
    $upd=mysql_query($sql); 
    

    Give it a Try !!!

    Other things to remember

    • If the table is MyISAM, it should run immediately
    • If the table is InnoDB, make sure autocommit = 1

    UPDATE 2011-12-15 15:28 EDT

    Try putting 'or die' after the $upd=mysql_query($sql); and see what mysql-based error message comes back

    评论

报告相同问题?

悬赏问题

  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)