Question: Please help me, I am having trouble seeing if a value exists within my database named I think the problem is rooting from mysql_result. How
Please help me, I am having trouble seeing if a value exists within my database named I think the problem is rooting from mysql_result. How do I make this mysqli compatible ?
---------------------------------------------------------------
$connect_error = 'Error message'; global $con = mysqli_connect('localhost','root',' '); mysqli_select_db($con,'loginandreg') or die($connect_error);
?>
-----------------------------------------------------------------
function sanitize($data) { $username = sanitize($username); return mysqli_real_escape_string($data); //whatever data we insert, we will sanitize it by using this and return the data } ?>
--------------------------------------
function user_exists($username) { $query = mysqli_query("SELECT COUNT(`user_ID`) FROM `users` WHERE `username` = '$username'"); return (mysql_result($query, 0)==1,) ? true : false; }
?>
-------------------------------------------------------------------------------------------
//using this to check if there is a connection.to database
include 'core/init.php';
if(user_exists('george')===true) //geroge is the name of ther username within my database loginandreg { echo 'exists'; } die();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
