mysql_num_rows+报错,php - PHP错误:警告:mysql_num_rows()期望参数1为资源[重复] - 堆栈内存溢出...

这是完整的错误

警告:mysql_num_rows()期望参数1为资源,在第35行的C:\\ xampp \\ Installations \\ htdocs \\ finished \\ register.php中给出布尔值用户名已存在查询为空

这是我的代码:

//Checks to make sure the submit button is pressed

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

$errors = array();

$valid = true;

//Checks to make sure the password meets the rules of validation

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

if(!preg_match('/^(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/',$_POST['Password'])) {

$errors ['Password'] = "Your password must have the following criteria - contain at least (1) upper case letter - contain at least (1) lower case letter - contain at least (1) number or special character - contain at least (8) characters in length";

echo $errors ['Password'];

$valid = false;

}

}

//Checks to make sure the email meets the rules of validation

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

if(!preg_match('/^([a-zA-Z0-9._-])+@[a-zA-Z0-9._-]+.([a-zA-Z]{2,4})$/',$_POST['Email'])) {

$errors['Email'] = "Must be valid email address";

echo $errors['Email'];

$valid = false;

}

}

if(empty($errors)) {

//This creates the connection to the database

$con = mysql_connect("localhost", "Peter", "password");

if(!$con) {

die("Can not connect:" . mysql_error());

}

//Selects the database I wish to add the table into

mysql_select_db("deepseadiving",$con);

//Passes the entered information into the table called user

$mysql=mysql_query("SELECT FROM User (Username) WHERE Username = '$_POST[Username]'");

if(mysql_num_rows($mysql)>=0)

{

echo"Username already exists";

}

else

{

$sql = "INSERT INTO User (Username,Password,FirstName,LastName,Email,Address,ContactNumber) VALUES('$_POST[Username]','$_POST[Password]','$_POST[FirstName]','$_POST[LastName]','$_POST[Email]','$_POST[Address]','$_POST[ContactNumber]')";

header("location:register.php");

}

mysql_query($mysql,$con) or die(mysql_error($con));

mysql_close($con);

}

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值