Reputation: 539
I seem to be having trouble getting mysqli to return a result from my query. My code is:
$db_conn = get_database(); //function returns a static mysqli object reference
if($result = $db_conn->query("SELECT city
FROM state
WHERE name='CA' ")) {
$row = $result->fetch_object();
$city= $row->city;
$result->close();
} else {
echo $db_conn->error;
}
When I echo the contents of the city variable, it contains nothing.
Upvotes: 1
Views: 545
Reputation: 70487
get_database()
to make sure the proper database is selectedstate
in your where clause is the same as your table name, state
. Change that to name
instead if you can.Upvotes: 1