So I have looked online about finding a way to convert a MySQL query count result into an integer for me to assign as a php variable, I had found several different links, and have read multiple documentation. None of them seem to cover exactly what I want. For example:
//code for connecting to database
$query = "SELECT COUNT(*) FROM `user_table` WHERE `username` = 'John12'";
$result = mysql_query($query);
if(!$result) die($db->error);
Now the code above after running the query should return 1, in the case that the username field is unique and there will only be one instance of that query result. Another example:
//code for connecting to database
$query = "SELECT COUNT(*) FROM `user_table` WHERE `username` = 'John12' AND `username` = 'Paula25'";
$result = mysql_query($query);
if(!$result) die($db->error);
Now the code above after running the query should return 2. What I been having trouble with is assigning the result to a php variable. It always says something about unable to convert mysql_result into int. I have seen plenty of forums on this as well, and none have successfully helped me. I have found online that the MariaDB return a BIGINT type for the count query. I would like to be able to do something like this:
$count = $result->result;
if($count < 2) {
// do this if true
} else {
// do this
}