pdo更新xampp中的工作但不能在服务器中工作

时间:2015-03-14 13:38:39

标签: php sql pdo

我使用此功能更新表格。

它在xamp和local中正常工作但在服务器上它返回此错误:

  

数组([0] => 42000 [1] => 1064 [2] =>您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便使用正确的语法靠近':WHERE id = 1'在

行附近
function update($sTable, $aValues = array(),$key,$debug = 0){

        global $pdo;
        unset($aValues['edit']);
        unset($aValues['update']);

        if (!empty($aValues) && !empty($sTable)){

            # validation of table / columns nam

            $aColumns = array_map('mysql_real_escape_string',array_keys($aValues));

            $aElements = array();

            foreach ($aColumns as $sColumn){

                $aElements[] = "`$sColumn`= :$sColumn";

            } // foreach

            $oPDOStatement = $pdo->prepare("UPDATE $sTable SET " . implode(',', $aElements)." WHERE `id`=$key");

            $oPDOStatement->execute($aValues);

            if($debug==1) print_r($oPDOStatement->errorInfo());

        }
    } 

0 个答案:

没有答案