Shinu Thomas
Shinu Thomas

Reputation: 5316

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 function sqlite_escape_string()I am using PDO for connecting the database.

Upvotes: 2

Views: 5428

Answers (5)

Mahmut Esinti
Mahmut Esinti

Reputation: 98

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);
    }
}

Upvotes: 2

WHOAMI
WHOAMI

Reputation: 121

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

Upvotes: 12

giraff
giraff

Reputation: 4711

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).

Upvotes: 1

Crozin
Crozin

Reputation: 44376

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.

Upvotes: 1

Wrikken
Wrikken

Reputation: 70460

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.

Upvotes: 6

Related Questions