我正在通过ODBC Filemaker表更新mysql 当一个字段包含o'reilly或example'two时,我收到以下错误消息:
警告:odbc_exec():SQL错误:[FileMaker] [FileMaker] FQL0001 /(1:80):
查询的语法有错误。第49行的C:\ fm_1.php中的SQLExecDirect中的SQL状态42000
并使用addslashes()不起作用。
谢谢你!这是我的代码:
<?php
$conn = odbc_connect("DSN=Server;Database=TEST;UID=odbc;PWD=1234", "odbc", "1234");
if ($conn)
echo "\nConnection established.";
else
die("\nConnection could not be established.");
$result = odbc_exec($conn, "SELECT ID_MH, MH_Name FROM myTable WHERE MH_Name LIKE '%EXAMPLE'");
while ($row = odbc_fetch_array($result)) {
$ID_MH = $row["ID_MH"];
$MH_Name = $row["MH_Name"];
// do something
$MH_Name = addslashes($MH_Name);
$update = "UPDATE myTable SET MH_Name='$MH_Name' WHERE ID_MH=" . $ID_MH;
$data_update = odbc_exec($conn, $update);
}
odbc_close($conn);
?>
答案 0 :(得分:0)
尝试逃避而不是使用addslashes:
&#34;更新myTable SET MH_Name = \&#34; $ MH_Name \&#34; WHERE ID_MH =&#34; 。 $ ID_MH;
答案 1 :(得分:0)
这是解决方案:
$query = 'UPDATE myTable SET MH_Name=? WHERE ID_MH=?';
$stmt = odbc_prepare ($conn, $query);
$success = odbc_execute($stmt, array($MH_Name, $ID_MH));
来源:https://www.skeletonkey.com/FileMaker_11_ODBC_Drivers/
谢谢!