Reply to Re: SQL Statement with DATE format

Your name:

Reply:


Posted by james.gauth on 06/25/07 11:24

On 25 Jun, 11:39, Andre Stumpf <andre.stu...@stumpfi.com> wrote:
> Hi,
>
> i want to compare dates. The dates are like "2007-06-25".
> I tried this:
> $SQLString = "SELECT * FROM myDB.myTABLE WHERE dat_start = $act_dat";
> But it didn't work.
> What can I do?
> Thank you!
>
> André

This problem is more than likely due to your dates not being inside
quotes in the SQL query. When substitution takes place, your SQL
string should end up similar to this:

SELECT * FROM myDB.myTABLE WHERE dat_start = '2007-06-25'

Whereas without quotes the query would fail because of the unquoted
literal:

SELECT * FROM myDB.myTABLE WHERE dat_start = 2007-06-25

If the dates are coming from user input, be careful not to allow a SQL
injection exploit

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация