Page 1 of 1

error with UPDATE command using PHP against Access 2000 db

Posted: Mon Feb 23, 2004 7:52 pm
by tremere
i have tried different combinations of writing my query string. what i am doing is updating information in a table, using a form that is populated with the data from that table. the form part is fine, it's the updating that is causing problems. I would very much appreciate assistance with this :)

here is what my database looks like:
database -> thoughts
table -> thoughts
fields -> thoughtsID (K, auto-increment), date (text), title (text), thoughts (memo)

my UPDATE statement looks like this:

(in browser):
UPDATE thoughts SET date='2122004', title='my birthday', thoughts='That was my birthday :-)' WHERE thoughtsID='1'

(in PHP):
// if this is a current record that was edited, then we do
// NOT want to create another record with the same data
if($_POST['id']) {
$i = $_POST['id'];
$query = "UPDATE thoughts SET date='$date', title='$title', thoughts='$thoughts' WHERE thoughtsID='$i'";
} else {
$query = "INSERT INTO thoughts([date], [title], [thoughts]) ";
$query .= "VALUES('$date', '$title', '$thoughts')";
}

the error being printed to the browser is:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement., SQL state 37000 in SQLExecDirect in f:\programs\servers\apache\websites\ddott\write2.php on line 67
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

This is driving me absolutely nuts, as I am using Access 2000 because I couldn't get MySQL installed and working on my WindowsXP Professional box here at home.

Posted: Tue Feb 24, 2004 6:17 pm
by AVATAr
1. did you try executing the update statement directly in the DB? i dont know if you can do it with access... buy with something like msft query...

2. did you try using:
$query = 'UPDATE thoughts SET date="'.$date.'", title="'.$title.'", thoughts="'.$thoughts.'" WHERE thoughtsID='.$i;

3. did you try using:
$query = 'INSERT INTO thoughts SET date="'.$date.'", title="'.$title.'", thoughts="'.$thoughts.'"';

4. you can download php+mysql+apache+phpmyadmin for your xp pro box here: http://www.easyphp.org/?lang=en