Adding a string directly, without quotes (and escaped quotes within the value) will not work if that is your question.
The following will work with integers if you match in a numbers field, but it will not work with strings:
$query = "SELECT * FROM posts WHERE fruit = $fruit_type";
To match strings, you must enclose them in single quotes and avoid single quotes occurring inside the value. Below, the quotes contained in the passed variable will not be executed:
$query = "SELECT * FROM posts WHERE fruit = '$fruit_type'";
At least you should do this:
$query = "SELECT * FROM posts WHERE fruit = " . mysql_real_escape_string($fruit_type);
And as soon as possible read about it:
http://php.net/manual/en/pdo.prepared-statements.php
source share