i am trying to update a Table on FileMaker but am getting this error:
Warning: odbc_exec(): SQL error: [FileMaker][FileMaker] FQL0001/(1:90): There is an error in the syntax of the query., SQL state 42000 in SQLExecDirect in C:...
here is my code:
$conn = odbc_connect("DSN=Server;Database=FM_File;UID=odbc;PWD=1234", "odbc", "1234");
$result = odbc_exec($conn, "SELECT ID_FM, Street FROM Table WHERE Street LIKE '%AVENUE%'");
while ($row = odbc_fetch_array($result)) {
$ID_FM = $row["ID_FM"];
$Street = $row["Street"];
$Street_neu = str_replace("AVENUE", "AV", $Street);
$update = "UPDATE Table SET Street='$Street_neu' WHERE ID_FM=" . $ID_FM;
$data_update = odbc_exec($conn, $update);
}
odbc_close($conn);
thank you!
As your error states you have incorrect syntax. I do not like $ in the string value, but this is probably OK. You can't use a table called Table in SQL statement - it is the reserved word. I would recommend changing the name. If you can't, try to escape it:
"SELECT ID_FM, Street FROM \"Table\" WHERE Street LIKE '%AVENUE%'"
and
"UPDATE \"Table\" SET Street='$Street_neu' WHERE ID_FM=" . $ID_FM;
FileMaker also uses its own notation for reserved words - ${reserveword}. I don't think it applies to its version of SQL, but you can try if the other one fails