date query problem, date in variable

This is a discussion on date query problem, date in variable within the MySQL Database forums, part of the Database Forums category; I am using the following query : $query_archief = "SELECT * FROM vacatures where dd_eind_plaatsing < $dd_eind_plaatsing_archief1" note: $dd_eind_plaatsing_archief1 = 2005-10-...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-16-2005
roy
 
Posts: n/a
Default date query problem, date in variable

I am using the following query :

$query_archief = "SELECT * FROM vacatures where dd_eind_plaatsing <
$dd_eind_plaatsing_archief1"

note: $dd_eind_plaatsing_archief1 = 2005-10-21

it seems the variable $dd_eind_plaatsing_archief1 is not exepted as a
proper date, what is the correct way to set up a query using a date
variable.





Reply With Quote
  #2 (permalink)  
Old 10-16-2005
Kai Ruhnau
 
Posts: n/a
Default Re: date query problem, date in variable

roy wrote:
> I am using the following query :
>
> $query_archief = "SELECT * FROM vacatures where dd_eind_plaatsing <
> $dd_eind_plaatsing_archief1"
>
> note: $dd_eind_plaatsing_archief1 = 2005-10-21
>
> it seems the variable $dd_eind_plaatsing_archief1 is not exepted as a
> proper date, what is the correct way to set up a query using a date
> variable.


Wrinting 2005-10-21 in your script language yields to the number 1974
(2005 minus 10 minus 21). The same is happening in the SQL-query.
You must quote the date properly:

WHERE dd_eind_plaatsing<'$dd_eind_plaatsing_archief1'

Please check for SQL-injection.

Greetings
Kai

--
This signature is left as an exercise for the reader.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:53 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0