Jump to content

SQL syntax error with quotations


stijn0713

Recommended Posts

Hello,

 

I get the following error: 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 'BETWEEN '1800-01-01' AND '2200-01-01'' at line 1

 

Here is the code:

 

// building query

 

$where = array();

if ( $_GET['sex'] != '') {$where[] = " geslacht = '$sex'"; }

if( $_GET['minAge'] != '' && is_numeric($_GET['minAge'])){ $where[] = " geboortedatum < '$minAge'"; }

if( $_GET['maxAge'] != '' && is_numeric($_GET['maxAge'])) {$where[] = " geboortedatum >= '$maxAge'"; }

$where[] = " TijdRegistratie BETWEEN '$minDatum' AND '$maxDatum'";

// glueing query

$sql = "SELECT * FROM respondenten";
if (count($where) > 0){   $sql .= "WHERE ".implode(" AND ", $where);}

 

Can somebody tell me where i've put the wrong quotations? *confused*

Link to comment
https://forums.phpfreaks.com/topic/259050-sql-syntax-error-with-quotations/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.