PHP脚本可检查唯一的电子邮件并将其插入数据库

时间:2018-12-15 12:37:43

标签: php mysql sql

有人可以帮助我发现错误,我得到的唯一输出是条件的其他部分“错误504”。

<?php
require "conn.php";
$username = $_POST["user_name"];
$password = $_POST["password"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$age = $_POST["age"];
$name = $_POST["name"];
$mysql_qry = "SELECT * FROM UserLoginDetails where email='$email'";
$result = mysqli_query($conn,$mysql_qry);
$num_rows = mysqli_num_rows($result);
if($num_rows >= 1){
    echo "email already exist";
}else{
    $mysql_qry = "Insert into UserLoginDetails (username, password, email, phone, age, name) values ('$username', '$password', '$email', '$phone', '$age', '$name')";
    $result = mysqli_query($conn,$mysql_qry);
    if($result >= 1){
        echo "Record";
    }
    else{
        echo "error 504";
    }
}
$conn->close();
?>

2 个答案:

答案 0 :(得分:0)

在DB中插入值时,它返回true或false,而不返回插入的记录或编号。

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        Log.e("NEW_TOKEN",s);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
    }
}

答案 1 :(得分:0)

插入时,您将收到true或false。不是数字。

所以你想做

var str = '( hello ) ehsan iran (how are) you';
console.log(
  str.match(/\([^()]*\)|\w+/g).filter(x => x[0] !== '(')
)

这是php网站上写的内容

  

在失败时返回FALSE。为了成功执行SELECT,SHOW,   DESCRIBE或EXPLAIN查询mysqli_query()将返回   一个mysqli_result对象为了其他成功   查询mysqli_query()将返回TRUE

http://php.net/manual/en/mysqli.query.php

如果问题仍然存在。也可能是您的年龄数据类型是数字,并且您正在通过引号传递字符串。删除年龄前后的引号。

var str = '( hello ) ehsan iran (how are) you';
console.log(
  str.match(/\w+(?![^()]*\))/g)
)