2014-03-03 28 views
0

我剛纔改變我的主機,我所有的PHP腳本之前工作的罰款用雙引號錯誤的PHP新的託管

,但現在我得到很多的MySQL錯誤是這樣的:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near column = \'value\' 

似乎有一些腳本中的雙引號

有沒有更新所有我的PHP腳本的解決方法?

編輯:例如PHP代碼

function test($table,$column, $where){ 

if(get_magic_quotes_gpc()) { $where = strip_tags(trim($where)); } 
else{ $where = strip_tags(mysql_real_escape_string(trim($where))); } 

$where = "AND id = '" . $where . "' "; 

$query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1"; 
//... 
+3

添加mysql + php代碼,使得更容易解決! –

+0

對不起,還在學習算命。 –

+0

好的我發佈了一個代碼示例,我認爲原因是magic_quote o註冊全球 – ipel

回答

1

你必須要麼通過$table變量或聲明爲全球性的,如果所定義的外部。

function test($column, $where){ 
global $table;  

if(get_magic_quotes_gpc()) { $where = strip_tags(trim($where)); } 
else{ $where = strip_tags(mysql_real_escape_string(trim($where))); } 

$where = "AND id = '" . $where . "' "; 

$query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1"; 
+0

它只是函數的一部分,$ table和$ query都可以,問題出在$ where,insted of call:id ='abc'它似乎已通過:id = \'abc \' – ipel

+0

請打印您的查詢 – 2014-03-03 10:08:26

0

如果你的函數看起來像這樣會發生什麼?

function test($table,$column, $where){ 
    $where=stripslashes($where); 
    $where = strip_tags(mysql_real_escape_string(trim($where))); 
    $where = "AND id = '" . $where . "' "; 
    $query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1"; 
}