I wrote this function that get user name and need to check if the user is already in the DB.
This is my code:
$conn = new mysqli($servername, $username, $password, $database, $dbport);
mysql_select_db("myDB",$conn);
//$sql="CALL checkIfExsist(".$name.")";
$sql = "select * from Users where userName='".$name."' LIMIT 1;";
$myData = $conn-> query($sql);
$rowc = mysqli_num_rows($myData);
printf("Result set has %d rows.\n", $rowc);
if($rowc > 0)
{
echo "User ".$name." checked";
}
else
echo "not exsist";
When I run this query in the terminal i get 1 row result, but in the consol I get: "Result set has 0 rows."
What is the problem?