Page 1 of 1

MS Access with PHP date help

Posted: Wed Dec 03, 2003 6:57 pm
by ericsodt
I have a function to create today's date:

Code: Select all

function today($DBdate){
  $date = getdate();
  $year = $dateї'year'];
  $day=$dateї'weekday'];
  $month=$dateї'month'];
  $DBmonth=$dateї'mon'];
  $numday=$dateї'mday'];
  $calendar = iif($DBdate,"$DBmonth/$numday/$year" ,"$day, $month $numday $year", true);
  return $calendar;
}
and I try and do an insert into the database:

Code: Select all

$getWO_id = "insert into workout_t (user_id, date) values (".$userID.", '".today(true)."') ";
  $insertted = odbc_exec($dbObj, $getWO_id);
and I am getting this error:
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in C:\apache\htdocs\insert_sets.php on line 14
insert into workout_t (user_id, date) values (10, '12/3/2003')

Can anyone think of anything why this would be happening???

Posted: Wed Dec 03, 2003 7:27 pm
by infolock
$calendar = iif($DBdate,"$DBmonth/$numday/$year" ,"$day, $month $numday $year", true);
looks like you have one too many i's in the if statement.

Posted: Wed Dec 03, 2003 7:37 pm
by ericsodt
iif is a function I wrote... I found out why it wasnt inserting... date has to be in brackets insert into blah [date] values ($date)
infolock wrote:
$calendar = iif($DBdate,"$DBmonth/$numday/$year" ,"$day, $month $numday $year", true);
looks like you have one too many i's in the if statement.