php - Convert mysql_result to mysqli_result -


i need help. convert mysql_result mysqli_result.

    function user_exists($username) {       $username = sanitize($username);        return (mysql_result(mysql_query("select count(`user_id`) `users` `username` = '$username'"), 0) == 1) ? true : false;     }      function user_exists($username) {       $username = sanitize($username);        return (mysqli_result(mysqli_query($con7,"select count(`user_id`) `users` `username` = '$username'"), 0) == 1) ? true : false;     } 

i tried adding code. still not working.

    function mysqli_result($res, $row, $field=0) {        $res->data_seek($row);        $datarow = $res->fetch_array();        return $datarow[$field];      } 

edited. $con7 such

    $con7 = mysqli_connect('localhost','root', '', 'database') or exit($connect_error); 


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -