I've been having some trouble. I'm trying to insert a record into an access database using odbc. I've got an entire website that works using the exact code i'm pasting below, the only differences are the insert statements. For some reason it won't let me insert into this database with the error below
I have the correct field names, order, and data types
any ideas?
thanks
mike
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in C:\Inetpub\wwwroot\fuel\fueledit.php on line 173
INSERT INTO monthly VALUES SET Year='2003', Month='Jun', File='monthly_reports/README.txt', Order='6'
Record not added, an error occurred : 37000
// connect to access database
$cfg_dsn = "DRIVER=Microsoft Access Driver (*.mdb);
DBQ=C:/Inetpub/wwwroot/fuel.mdb;
UserCommitSync=Yes;
Threads=3;
SafeTransactions=0;
PageTimeout=5;
MaxScanRows=8;
MaxBufferSize=2048;
php DriverId=281;
DefaultDir=C:/ProgramFiles/CommonFiles/ODBC/DataSources";
$cfg_dsn_login = "";
$cfg_dsn_mdp = "";
// Type, Desc, Year, File, ID
$connection = odbc_connect($cfg_dsn,$cfg_dsn_login,$cfg_dsn_mdp);
//$command = "INSERT INTO monthly VALUES SET Year='$year', Month='$month', File='$movestring', Order='$order'";
$command = "INSERT INTO monthly (Year, Month, File, Order) VALUES ('$year', '$month', '$movestring', '$order')";
if(odbc_exec($connection, $command)) {
echo("Record added successfully");
} else {
echo $command . "\n<br>";
unlink($movestring);
echo("Record not added, an error occurred : " . odbc_error() . "<br>\n");
}
odbc_close($connection);