MS Access with PHP date help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ericsodt
Forum Commoner
Posts: 51
Joined: Fri Aug 22, 2003 12:12 pm
Location: VA

MS Access with PHP date help

Post 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???
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
ericsodt
Forum Commoner
Posts: 51
Joined: Fri Aug 22, 2003 12:12 pm
Location: VA

Post 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.
Post Reply