开发者

Problem with sqlite_escape_string() In php

I have used sqlite_escape_string() function in one server and it is working fine.When i use the same code in anther server it throwing an error Call to undefined fun开发者_运维知识库ction sqlite_escape_string()I am using PDO for connecting the database.


function sqlite_escape_string( $string ){
    return SQLite3::escapeString($string);
}


sqlite_escape_string is part of the SQLite package, which is distincely different then the PDO_SQLite package. Go for prepared statements instead of escaping the variables.


if your php version lower than 5.4 maybe you can use this solution

if php version < 5.4

if(!function_exists('sqlite_escape_string')){
    function sqlite_escape_string($string) {
        return str_replace("'", "''", $string);
    }
}


sqlite_escape_string() function is from sqlite extension whereas pdo_sqlite is "only" a driver for PDO.

You should definitely go for PDO and prepared statements in your projects.


sqlite_escape_string() is not part of the PDO interface, these are object oriented. Additionally, it is only Sqlite Version 2, while the PDO interface is version 3.

See Installation (which specifies that sqlite_pdo is necessary if you're on windows).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜