php7.3 mysql 500错误,为什么我的PHP总是出现500错误?

I am trying to create an account registration page and when I add a system to check the database and make sure that there are not multiple rows with the same username, I get a 500 error.

Here's the code that works:

if(isset ($_POST['submit']))

{

include( 'connection.php' );

$username = $_POST['username'];

$password = $_POST['password'];

$email = $_POST['email'];

if(empty($username) || empty($email) || empty($password))

{

echo 'Please check the required fields.';

}

elseif(!filter_var($email,FILTER_VALIDATE_EMAIL))

{

echo 'Please enter a correct email address.';

}

else

{

$password = md5($password);

$sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password')") or die(mysql_error());

if($sql)

{

echo 'Successfully submitted.';

}

}

}

?>

Here's the code that gives me a 500 error:

error_reporting(E_ALL)

if(isset ($_POST['submit'])) {

include( 'connection.php' );

$username = $_POST['username'];

$password = $_POST['password'];

$email = $_POST['email'];

$fetch = mysql_query("SELECT * FROM users WHERE username = '$email'") or die(mysql_error();

$num_rows = mysql_num_rows($fetch);

if(empty($username) || empty($email) || empty($password)) {

echo 'Please check the required fields.';

}

elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)) {

echo 'Please enter a correct email address.';

}

elseif($num_rows >= 1);

{

echo 'This username is taken.';

else

}

$password = md5($password);

$sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password')") or die(mysql_error());

if($sql)

{

echo 'Successfully submitted.';

}

}

}

?>

解决方案

You missed a semi-colon off your first statement

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值