I have this join in a prepare statement
//validate slug
$pro = $mysqli->prepare("SELECT
profiles.Image,
members.URLName,
members.DisplayName,
profiles.Pieces,
profiles.AboutMe,
profiles.DA,
profiles.TB,
profiles.SK
FROM `profiles`
INNER JOIN `members`
ON profiles.userID = members.ID
WHERE members.URLName = ?");
$pro->bind_param('s',$_GET['urlslug']);
$pro->execute();
$pro->store_result();
It returns nothing, even when an expected input is provided. I believe this is because I can't put apostrophes around the input (unless I wanted to search for the URLSlug "?").
The query itself is fine I believe. If I run the SQL with the input 'user1' WITHOUT apostrophe's in PHPMyAdmin it tells me:
#1054 - Unknown column 'user1' in 'where clause'
And with apostrophe's, it works
Showing rows 0 - 0 ( 1 total, Query took 0.0030 sec)
How do I get my prepare statement to include the necessary apostrophe's around the input and work?
Edit1: Output of:
var_dump($_GET['urlslug']) = string(5) "user1"
Working query straight from PHPMyAdmin:
SELECT profiles.Image,
members.URLName,
members.DisplayName,
profiles.Pieces,
profiles.AboutMe,
profiles.DA,
profiles.TB,
profiles.SK
FROM `profiles`
INNER JOIN `members` ON profiles.userID = members.ID
WHERE members.URLName = 'user1'
Edit2: This is not a duplicate. I'm not asking how to protect against SQL injections with prepare statements I'm saying that the following statement doesn't work without apostrophe's around 'user1' and how do I achieve that without putting apostrophe's around the "?" in my prepare statement:
SELECT profiles.Image,
members.URLName,
members.DisplayName,
profiles.Pieces,
profiles.AboutMe,
profiles.DA,
profiles.TB,
profiles.SK
FROM `profiles`
INNER JOIN `members` ON profiles.userID = members.ID
WHERE members.URLName = user1