I'm trying to find a list of people's names that match a search. My php:
require "accessControl.php";
require "sqlLink.php";
$string = "%dan%";
// create a prepared statement
if ($stmt = $link->prepare("SELECT full_name FROM (SELECT *, CONCAT(firstname," ",lastname) AS full_name FROM users) tmp WHERE full_name LIKE ?")) {
$stmt->bind_param("s", $string);
$stmt->execute();
$stmt->bind_result($result);
$stmt->fetch();
$stmt->close();
}
echo $result;
This just gives a 500 error, but when I replace the query with "SELECT lastname FROM users WHERE firstname LIKE ?"
, it works fine. I spent over an hour searching for a solution, but I'm pretty confused.