Avatar of namsu55
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

PHP Function not Working

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.
function myFunction()
$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>";

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon