-1

这是我得到的mysql错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECY * FORM user WHERE username='' AND password='' LIMIT 1' at line 1

这是我的代码:

<?php
session_start();
include_once("connect.php");

if (isset($_POST['username'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $sql = "SELECY * FORM users WHERE username='".$username."' AND password='".$password."' LIMIT 1";
    $res = mysql_query($sql) or die(mysql_error());
    if (mysql_num_rows($res) == 1) {
        $row = mysql_fetch_assoc($res);
        $_SESSION['uid'] = $row ['id'];
        $_SESSION['username'] = $row ['username'];
        header("Location: index.php");
        exit();
    } else {    
        echo "Invalid login information. Please return to the previous page.";
        exit();
    }
}
?>

有人可以帮助我吗?:) 我不知道我在这里做什么,找不到错误。

4

2 回答 2

2
SELECY

是印刷错误,请尝试:

SELECT
于 2013-08-25T11:06:14.397 回答
1
$sql = "SELECY * FORM users 
WHERE username='".$username."' 
AND password='".$password."' 
LIMIT 1";

更改SELECYSELECT和。FORM_FROM

正确的查询应该是:

$sql = "SELECT * FROM users 
WHERE username='".$username."' 
AND password='".$password."' 
LIMIT 1";
于 2013-08-25T11:06:43.607 回答