开发者

Unknown column 'Date' in 'where clause'

I have the following query:

select * from invoice WHERE Date >= '$date' AND status='$status'

It returns an error:

Unknown column 'Date' in 'where clause'

I am not too good in PHP or MYSQL, but I dont see anything wrong. There is probably everything wrong though. I need assistance!

EDIT:

$var = $_GET['date1_year'] ."-" . $_GET['date1_month'] ."-" . $_GET['date1_day'];
$query = "select * from invoice WHERE DateOfCreation >= '$var' AND status='$status'";

And ofcourse it is logged in(authenticated) and is being exec开发者_运维问答uted with no errors, but no proper result either. My DateOfCreation is a DATE type and there are actually the $_GET variables. I want it to search for all records before $var.


select * from invoice WHERE DateOfCreation >= '$date' AND status='$status'

While it would work, I encourage you to look into parameterized queries in order to prevent SQL injection attacks. See here: How can I prevent SQL injection in PHP?


for all records before $var

So you mean this then? (changed >= to <)

$var = $_GET['date1_year'] ."-" . $_GET['date1_month'] ."-" . $_GET['date1_day'];
$query = "select * from invoice WHERE DateOfCreation < '$var' AND status='$status'";

With your EDIT, I assume this error is gone?

Unknown column 'Date' in 'where clause'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜