2013-05-30 112 views
1

嗨,大家好我需要幫助SQLite - sqlite_escape_string()在PHP中。 下面是一個代碼:致命錯誤:調用PHP中未定義的函數sqlite_escape_string()

<?php 
require_once('AES/AES_Encryption.php'); 
require_once('AES/padCrypt.php'); 

$database = new PDO('sqlite:example_sqlite3.db'); 

$key = "bac09c63f34c9845c707228b20cac5e0"; 
$iv = "123456789";      
$AES = new AES_Encryption($key, $iv); 

$Col1 = '123456789qwerty'; 
$Col2 = 'qwerty123456789'; 

$encrypted_1 = sqlite_escape_string($AES->encrypt($Col1)); 
$encrypted_2 = sqlite_escape_string($AES->encrypt($Col2)); 

INSERT INTO AES_T (encrypted_1 , encrypted_2) VALUES ('$encrypted_1', '$encrypted_2'); 

echo "ENC1:" . $encrypted_1; 
echo "ENC2:" . $encrypted_2; 
?> 

好吧,這ecnryption在MySQL工作與mysql_real_escape_string()。 使用sqlite_escape_string()它報告:致命錯誤:調用未定義的函數sqlite_escape_string()。 AES PHP加密:對加密我使用這個:http://www.coderelic.com/2011/10/aes-256-encryption-with-php/

我檢查的phpinfo()和我已經啓用:

  • PDO驅動程序:MySQL的
  • sqlite的啓用
  • PDO驅動程序的SQLite 3。 X啓用
  • SQLite庫3.7.7.1啓用
  • sqlite3的支持sqlite3的模塊版本0.7啓用
  • SQLI TE圖書館3.7.7.1啓用

我使用WAMP服務器Apache的版本22年2月22日和PHP版本5.4.3我tryed與Zend Server和定期Apache和PHP安裝目錄和一個同樣的錯誤。請爲此需要幫助。

回答

4

sqlite_escape_string在PHP 5.4中已棄用。轉義數據庫字符串的最好方法是使用PDO,就像這裏建議的那樣escaping strings for SQLite3 in PHP5

+0

雖然我同意這個答案,但不推薦使用與已刪除的不同。它應該仍然在理論上工作,不是嗎? – crush

+0

確定如此insted:$ encrypted_1 = sqlite_escape_string($ AES-> encrypt($ Col1));我必須使用這個:$ encrypted_1 = SQLite3 :: escapeString($ AES-> encrypt($ Col1)); – djpetrovic

+0

是的,我的錯誤...它被刪除。正如您從手冊中看到的,它僅在低於5.4的版本上可用。 http://php.net/manual/en/function.sqlite-escape-string.php – lexmihaylov

相關問題