TJE
TJE

Reputation: 240

Call to undefined method DB::escape_string()

Here is simplified version of my code:

$db = new mysqli('localhost', 'user', 'pass', 'database') or die(mysqli_error());    

$gender = $db->escape_string($_GET['gender']);
$city = $db->escape_string($_GET['city']);

Here is the error I get:

Call to undefined method DB::escape_string() in /blablabla/bla/file.php on line 2

Why am I getting an error?

Upvotes: 0

Views: 4015

Answers (2)

John Conde
John Conde

Reputation: 219814

I think what you're looking for is mysqli::real_escape_string()

$gender = $db->real_escape_string($_GET['gender']);
$city = $db->real_escape_string($_GET['city']);

Upvotes: 2

echo_Me
echo_Me

Reputation: 37233

escape_string is an alias to real_escape_string, so they're identical.

here's a link for documentation:

http://php.net/manual/en/mysqli.real-escape-string.php

try this

 $city = $mysqli->real_escape_string($_GET['city']);

Upvotes: 0

Related Questions