I have a mysql table like this
name adults children
single 1 0
double 2 0
suite 3 0
But I'm unable to retrieve the values of "adults" and "children" with this function
function getInfo($mysqli, $c, $query){
// WARNING! THIS LINE IS NOT THE SQL QUERY BUT JUST AN ERROR LOG!
error_log("query is: SELECT " . $query . " FROM categories WHERE `name` = " . $c);
$mysqli->select_db("hotel");
$sql = $mysqli->prepare("SELECT ? FROM categories WHERE `name` = ?
LIMIT 0, 999999");
$sql->bind_param('ss', $query, $c);
$sql->bind_result($result);
while ($sql->fetch())
return($result);
}
error log shows the variables are correctly passed to the function:
[15-Apr-2013 19:36:10] SELECT adults FROM categories WHERE `name` = single
why is this function returning NULL
?