Reputation: 240
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
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
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