So I have a function to gather user_data
in PHP & MYSQL, and the thing is that I want to upgrade MYSQL
in MYSQLi
.
The MYSQL
code is following:
$data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM members where id = $id"));
The MYSQLi
code I tried but with no use:
$data = $db_connect->query("SELECT $fields FROM ´members´ where id = $id");
and
$result = $db_connect->query("SELECT $fields FROM ´members´ where id = $id");
$data = $result->fetch_assoc();
I don't know what could be wrong, in the 1:st example I have no errors but the data isn't displaying, and in the 2:nd code I noticed I need the fetch_assoc
function to make it work, but here I get the errors saying
Call to a member function fetch_assoc() on a non-object