我收到了这个错误。我认为'
$_POST
放错了$_POST['regno']
,但如果我这样做(例如T_ESCAPED
),则会出现$sql = "SELECT * FROM students WHERE RegNo='$_POST[regno]' AND
password='$_POST[password]' AND Status='Enabled'";
错误。
我怎么解决这个问题?
这是第33行的代码:
{{1}}
我使用Wamp作为我的本地主机。 谢谢!
答案 0 :(得分:1)
您需要像这样检查帖子值
$reg_no = isset($_POST['regno']) ? $_POST['regno'] : '';
$sql = "SELECT * FROM students WHERE RegNo='".$reg_no."' AND password='".$_POST['password']."' AND Status='Enabled'";
答案 1 :(得分:1)
首先确保您的变量在尝试保存之前存在:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-catalog="QLSACH" match-schema="dbo" match-name="DanhMuc"/>
<table-filter match-catalog="QLSACH" match-schema="dbo" match-name="sach"/>
</hibernate-reverse-engineering>
还要记住,像这样使用POST var会暴露于SQL注入。
答案 2 :(得分:0)
试试这个:
$sql = "SELECT * FROM students WHERE RegNo='".$_POST['regno']."' AND password='".$_POST['password']."' AND Status='Enabled'";