I know this is very basic but i am not able to get the fuction return a string. Instead it is returning the value 1. Below is the code:
<?php
function getUserRole($username, $roleid){
include "data.php";
$con=dbConnect();
$query="select * from user inner join userrole on user.id = userrole.userid inner join role on role.id = userrole.roleid ";
$sql=$con->prepare($query);
$sql->bindValue(':username',$username);
$sql->bindValue(':roleid',$roleid);
$sql->execute();
$row = $sql->fetch();
if($row > 0){
return true;
}
else{
return false;
}
}
print getUserRole('admin',$roleid);
?>
The tables look as follows
mysql> select * from user;
+----+----------+----------------------------------+
| id | username | password |
+----+----------+----------------------------------+
| 1 | kamau | 80ce10e582e13ec085f13409c3add5a4 |
| 2 | admin | db43b86da58631629adada27f1db5841 |
+----+----------+----------------------------------+
2 rows in set (0.00 sec)
mysql> select * from role;
+-----------+----------------------------------+
| id | description |
+-----------+----------------------------------+
| admin | add, remove and edit manuscripts |
| reviewer | review manuscripts |
| site user | read manuscripts |
+-----------+----------------------------------+
3 rows in set (0.00 sec)
mysql> select * from userrole;
+--------+---------------+
| userid | roleid |
+--------+---------------+
| 1 | administrator |
| 2 | reviewer |
| 3 | other |
+--------+---------------+
3 rows in set (0.00 sec)
What can i be possibly doing wrong?