dongnong7524 2015-12-02 07:07
浏览 25
已采纳

登录进程解析错误:语法错误[重复]

This question already has an answer here:

hello guys please help me with my code in login process there's an error message

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

in line $_SESSION['userid'] = $row['userid'];

Here's my complete code of loginprocess:

session_start(); 
$message = "";

if(count($_POST) > 0){
    $conn = mysql_connect("localhost", "root", "");
    mysql_select_db("etransmittal", $conn);
    $result = mysql_query("SELECT * FROM tbl_userlist WHERE username = '" . $_POST["username"] . "' AND user_password = '" . $_POST["password"] . "');
    $row = mysql_fetch_array($result);

    if(is_array($row)){
        $_SESSION['userid'] = $row['userid'];
        $_SESSION['username'] = $row['username'];
    }
    else{
        $message = "Invalid username or password";
    }
}

if(isset($_SESSION['userid'])){
    header("location: userhomepage.php");
}
</div>
  • 写回答

2条回答 默认 最新

  • dongtangjie0495 2015-12-02 07:11
    关注

    You had one double quote missing, I have fixed it :

    $result = mysql_query("SELECT * FROM tbl_userlist WHERE username = '" . $_POST["username"] . "' AND user_password = '" . $_POST["password"] . "'");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 准备学习小程序搭建,谁能手把手的教我啊?
  • ¥15 关于#嵌入式硬件#的问题:树莓派第一天重装配置python和opencv后第二天打开就成这样,瞎捣鼓搞出来文件夹还是没把原来的界面调回来
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥100 AT89C52单片机C语言调试之后再回答
  • ¥15 AT89C52单片机C语言串口助手发送数据包返回值
  • ¥15 C++数组中找第二小的数字程序纠错
  • ¥50 MATLAB APP 制作出现问题
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)