Hello peeps!
I've been plugging away at this since 10pm, and it's almost 2am now. What I want to do is update a record in the database. Here is the scenario. I create a record, then view the records. For each record being viewed, I can edit or delete that record. I choose to edit the record. So, data is pulled from the record and put into a form, where I can "edit" what is in the form. I then click submit and away we go. What should happen is that the text in the form replaces whatever is in the referencing record in the database. Instead, what I get is an SQL error, which looks Chinese to me. The error is very little help, though it does indicate that I have a syntax error (I think). If the record already exists in the database, then I do the update. Otherwise, the same form that is used to "create" records will just give me an empty form.
Here is the error that shows in my browser:
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 51
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
Here is the code for the portion that does the updating:
// 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, title, thoughts) VALUES('$date', '$title', '$thoughts') WHERE thoughtsID='$i'";
} else {
$query = "INSERT INTO thoughts([date], [title], [thoughts]) ";
$query .= "VALUES('$date', '$title', '$thoughts')";
}
$query = odbc_exec($odbc, $query) or die (odbc_errormsg());
It's probably something very simple that I'm missing, but on the other hand it's been ages since I played with PHP (just a hobbyist here who is trying to make a website). Any help is appreciated :-)