I am upgrading my small project from MYSQL database into MYSQLi and I have only 3 functions left to update.
This is my function in MYSQL:
function id_from_username($username) {
$username = sanitize ($username);
return mysql_result(mysql_query("SELECT ´id´ FROM ´members´ WHERE ´username´ = '$username'"), 0, 'id');
}
I have this code which I tried to migrate into the function above but no use:
$result = "SELECT * FROM `settings`";
if (!$row = $db_connect->query($result)) {
die('Oops, something went wrong during loading data! Error x010');
}
I know I am supposed to public the code I tried out, but the problem is I do not really know how to migrate the MYSQLi into just that specific function and I know that the code was wrong in all ways possible if so to say.
I found the right answer, the code should be following:
It’s simple and I still can stick to my code without integrating other scripts 🙂