I’m trying to do the following:
$query = 'Select first_name, last_name , user_name FROM table1 WHERE fullname = "$name_given"'
Where fullname is first_name + ‘ ‘ + last_name so shouldn’t it look like:
$query = 'Select first_name, last_name FROM table1 WHERE concat(first_name, ' ', last_name) = "name_given"'
Except it doesn’t work… tells me there isn’t a column like that… and I don’t store full name anywhere (and I don’t think I’m allowed to add it) … any help please?
EDIT: Oops, typed it in here wrong. I didn’t copypasta’d it so yeah… syntaxically it was right…
EDIT2: FOUND IT. Apparnelty I need to put \”$name_given\” unless it’ll just assume it’s part of the quote… Thank you very much for answering my very poorly worded question.
Because you are concatenating
firstnameandlastname, notfirst_nameandlast_name(note the missing_).Also, please do NOT use a variable unescaped in a query! Always escape it: