PHP escape_string返回0。注册系统

时间:2018-11-18 11:58:59

标签: php database

<?php
$dbusername = "root";
$dbpassword = "";
$dbserver = "localhost";
$db = "data";
$con = mysqli_connect($dbserver, $dbusername, $dbpassword, $db);
if($con->connect_error){
    die('Error ' . $con->connect_error);
}
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];
$id = rand(100, 1000000);
$usernamea = $con->escape_string($username);
$passworda = $con->escape_string($password);
$emaila = $con->escape_string($email);
$ida = $con->escape_string($id);
$sql = "INSERT INTO logindata (usern, passw, email, id) Values('$usernamea', '$passworda', '$emaila', '$ida')";
$con->query($sql);
?>

<html>
<head>
<script Language="JavaScript" type="text/javascript">location.replace("../index.php")</script>
</head>
<body>

</body>
</html>

escape_string在$ sql字符串中仅返回0。 我正在尝试在MySQL PHP Html和其他代码中创建注册系统。.请帮助

1 个答案:

答案 0 :(得分:-1)

我修复了它。 Localhost PHPmyadmin的字符串已转换为int,而int转换为字符串。