dqcj32855 2012-05-15 13:21
浏览 43
已采纳

从id检索用户信息

I am working on a web app and am having trouble with a trivial issue. I have a table in a database, persons, which consists of the following fields: id, position (in company), username, firstname, lastname. I am working on an edit_user page. I have a main page listing the first+last names of all the users. I can then click on the names and this takes me to the edit_user page corresponding to that user. However, the updates that I make on the website do not get sent to the database (see code below).

//Inserting updates into database
        $query = "UPDATE person SET
            privilege  = '{$privilege}',
            nexus = '{$nexus}',
            firstname ='{$firstname}',
            lastname = '{$lastname}'"; 
        $query .="  WHERE id={$personid}";
        $result = mysql_query($query,$connection); 
        if (mysql_affected_rows() == 1) { 
            $message = "User was successfully updated"; 
        } else { 
            $message = "User was not updated";
            $message .= "<br/>" .mysql_error();
        }

My premonition is that something is wrong with the {$personid}, which was defined by:

function find_selected_user() {
    global $user;
    if (isset($_GET['personid'])) { 
        $personid = $_GET['personid'];
        return $personid
    } else {
        $user = NULL; 
    }
}

(the above function is supposed to return an array of $user's information) Please help -- I am so stuck! I am sure it is so simple but I've been thinking about it too long

  • 写回答

2条回答 默认 最新

  • douxiong2999 2012-05-15 13:25
    关注

    You forgot the ending ; character here:

    return $personid
    

    Should be:

    return $personid;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路