Question

Hi there i'm trying to convert the following function into MySQLi. I have done some but I can't figure out the rest. Can you help me?

function user_exists($username) {
$connect = mysqli_connect("host", "user", "password", "table") or die("Sorry, we are experiencing technical difficulties. Please try again later.");

$username = sanitize($username);
$query = mysqli_query($connect, "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}
Was it helpful?

Solution

You are mixing mysqli and mysql functions.you mea to use mysqli_result?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top