【问题标题】:Fatal error: Call to undefined function sqlite_escape_string() in PHP致命错误:在 PHP 中调用未定义函数 sqlite_escape_string()
【发布时间】:2013-05-30 14:19:00
【问题描述】:

大家好,我需要有关 SQLite 的帮助 - 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 = "1234567890123456";                    
$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;
?>

好的,这个加密在 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 已启用
  • 已启用 SQLite 3.x 的 PDO 驱动程序
  • SQLite 库 3.7.7.1 已启用
  • SQLite3 支持 SQLite3 模块版本 0.7 启用
  • SQLite 库 3.7.7.1 已启用

我正在使用 WAMP Server Apache 版本 2.22.22 和 PHP 版本 5.4.3,我尝试使用 Zend Server 以及常规的 Apache 和 PHP 安装,但出现相同的错误。请在这方面需要帮助。

【问题讨论】:

    标签: php apache sqlite aes


    【解决方案1】:

    sqlite_escape_string 在 php 5.4 中已弃用。转义数据库字符串的最佳方法是使用此处建议的 PDO escaping strings for SQLite3 in PHP5

    【讨论】:

    • 虽然我同意这个答案,但 deprecated 与 remove 不一样。理论上它应该仍然有效,不是吗?
    • 好的,所以插入:$encrypted_1 = sqlite_escape_string($AES->encrypt($Col1));我必须使用这个: $encrypted_1 = SQLite3::escapeString($AES->encrypt($Col1));
    • 是的,我的错误......它已被删除。从手册中可以看出,它仅适用于低于 5.4 的版本。 php.net/manual/en/function.sqlite-escape-string.php
    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 2016-02-20
    • 2014-07-21
    • 2016-07-02
    • 1970-01-01
    • 2016-11-21
    相关资源
    最近更新 更多