php - Get the value that comes after the ? operator in the URL
I want to get the value that will come after the '?' operator, for example:
www.blabla.com/any.php?h r u
I want to get this value "h r u", and to search this key in my database. I've already tried this:
$_SERVER["QUERY_STRING"]
This function is working fine but when I searched these values it prints like this "h%20r%20u" in my database from this query:
$query="SELECT * FROM databasename WHERE colum LIKE'%$link%'";
It will print link this " h%20r%20u no record found " and my database can't find this value. How can i solve my problem?
Answer
Solution:
Check out the urldecode function.
Answer
Solution:
You should, as pointed out, use
urldecode($string)
. For SQL Injections, just escape the value in your query:if you use mysql or mysqli to make queries. Use
PDO::quote
instead to escape if you use PDO.