Reputation: 433
I have a strange problem on a script php.
Using a search form I have categorie and city.
I get this using var_dump($_REQUEST); or GET
array(4) {
["q"]=> string(0) ""
["categorie"]=> string(1) "2"
["city"]=> string(1) "1"
["PHPSESSID"]=> string(32) "81cce71a1ffe8e7793366b06e15225fc"
}
on my php code I have
$Categorie = mysql_real_escape_string($_GET["categorie"]);
$City= mysql_real_escape_string($_GET["city"]);
also tried REQUEST
$Categorie = mysql_real_escape_string($_REQUEST["categorie"]);
$City= mysql_real_escape_string($_REQUEST["city"]);
But if I do
echo $Categorie;
echo $City;
I don't get any result.
Is there any explanation for this?
Upvotes: 0
Views: 1390
Reputation: 11832
Do phpinfo();
and check if mysql
is installed. Maybe you have only mysqli
installed, but not mysql
installed. That would cause mysql_real_escape_string()
to not work. In that case you can try mysqli_real_escape_string()
instead.
Upvotes: 0
Reputation: 78984
Based on your comment, use mysqli
, and it needs the link identifier:
$Categorie = mysqli_real_escape_string($your_link, $_GET["categorie"]);
$City= mysqli_real_escape_string($your_link, $_GET["city"]);
Upvotes: 2
Reputation:
From previous expierence, I have found that mysqli doesn't seem to work well with mysql_real_escape_string, have a look at using it like this:
http://www.php.net/manual/en/mysqli.real-escape-string.php
I find mysql_real_escape_string to be outdated though
It states in the PHP manual that mysql_real_escape_string is deprecated
http://php.net/mysql_real_escape_string
It also gives suggestions what to use instead.
Upvotes: 0