Php SQL语法中的错误
下面是我得到的mysql错误:Php SQL语法中的错误,php,mysql,sql,Php,Mysql,Sql,下面是我得到的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_s
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();
}
}
?>
有人能帮我吗?:)
我不知道我在这里做什么,找不到错误
SELECY
如果是印刷错误,请尝试:
SELECT
将选择
更改为选择
并将表单
更改为FROM
正确的查询应该是:
$sql = "SELECT * FROM users
WHERE username='".$username."'
AND password='".$password."'
LIMIT 1";
正确的拼写是
SELECT
,而不是SELECY
。这也是我见过的最疯狂的问题,但当你在学习东西的时候,它是可以的。请在这里发布之前至少看看你的查询。
$sql = "SELECT * FROM users
WHERE username='".$username."'
AND password='".$password."'
LIMIT 1";