Avatar of namsu55
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>";
 
 
} 
 
 
 
}
 
myFunction;

Open in new window

PHP

Avatar of undefined
Last Comment
pvginkel

8/22/2022 - Mon