My code works outside of a function, but when using a function it doesnt work. I even tried a suggested solution of writing return null at the end of the function but it did not work, can you please assist me.
$tablename = "login";
$sql = "SELECT * FROM $tablename WHERE username = '$_POST[username]'";
$result = @mysql_query($sql, $connection) or die(mysql_error());
$num = mysql_num_rows($result);
if ($num != 0)
echo "<h5>Logged in Username has Already been taken</h5>";