0
我在我的課上有以下靜態方法。靜態方法X mysql_real_escape_string()
public static function GETSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""){}
該方法我有這些下面的說明內:
if(function_exists("mysql_real_escape_string")){
$theValue = mysql_real_escape_string($theValue);
echo "a: " . $theValue;
} else {
$theValue = mysql_escape_string($theValue);
echo "b: " . $theValue;
}
當我運行該程序,被印刷在屏幕上 「A:」。這意味着$ theValue失去了他的價值。
我做錯了什麼?
你真的連接到數據庫嗎?你需要一個有效的'mysql_real_escape_string()'連接才能正常工作。無論如何,如果沒有看到所有方法的定義,我們都無法幫助。 –
它可能無助於回答你的問題,但你應該停止使用'mysql_ *'函數。他們正在被棄用。請使用[PDO](http://php.net/manual/en/book.pdo.php)(自PHP 5.1起支持)或[mysqli](http://php.net/manual/en/book)。 mysqli.php)(自PHP 4.1起支持)。如果您不確定要使用哪一個,請閱讀本文(http://www.deprecatedphp.com/mysql_/)。 – Matt
請顯示整個方法和對它的調用。 – Alfwed