MS Access and Dates

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
mrdall
Forum Newbie
Posts: 1
Joined: Mon Mar 27, 2006 7:27 am

MS Access and Dates

Post by mrdall »

Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


The code,

Code: Select all

$Conn = odbc_connect ('news', 'root', '') or die('Could Not Connect to ODBC Database!');

$entry = $_POST['news'];
$entryDate = mktime(0, 0, 0, 2, 2, date('Y'));

$query="
  INSERT INTO 
  news(date, news) 
  VALUES(#".date('d/m/Y',$entryDate)."#, '$entry')
";[font=Tahoma]

if(odbc_prepare($Conn, $query)){
  odbc_exec($Conn, $query);
  //header("Location: index.php"); 
  //exit;
}else{echo '
  <html>
  <head>
    <title>Didnt work</title>
  </head>
  <body>
    <p>insert didnt work!</p>
    <p style="color: red;">'.odbc_errormsg().'</p>
  </body>
  </html>
';}
Error message,

Warning: odbc_prepare() [function.odbc-prepare]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLPrepare in C:\Server\htdocs\news\addingNews.php on line 16

insert didnt work!

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.


any help would be greatly appreciated.


Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

try changing your field name.

http://support.microsoft.com/?kbid=248738
Post Reply