嘿伙计:)所以我有一个注册页面,但我的查询返回布尔值false,我找不到任何解决方案来修复它。
<?php
session_start();
if(isset($_SESSION['username'])!=""){
header("Location: index.php");
}
require_once 'dbconnect.php';
$username = strip_tags($_POST['username']);
$email = strip_tags($_POST['email']);
$upassword = strip_tags($_POST['password']);
$medic = strip_tags($_POST['medic_input']);
$username = $dbcon->real_escape_string($username);
$email = $dbcon->real_escape_string($email);
$upassword = $dbcon->real_escape_string($upassword);
$check_email = $dbcon -> query("SELECT username from tbl_users WHERE username='$username'");
$count=$check_email->num_rows;
var_dump($count);
if($count==0){
$query = "INSERT INTO tbl_users(username,password,email,medic) VALUES ('$username','$upassword','$email,'$medic')";
var_dump($query);
if($dbcon->query($query) === TRUE){
header('Location: login.php');
}
else {
echo "Error while registering. Please try again!";
var_dump($dbcon->query($query));
}
}
else {
echo "Your username already exists!";
}
$dbcon->close();
?>
计数转储给出0,但对于查询,它给出布尔值false。我试着改变桌子,没有帮助。 当我尝试注册时,它给我“注册时出错。请再试一次!”;
答案 0 :(得分:1)
您的INSERT
查询中存在语法错误,并且缺少单引号,如下所示
VALUES ('$username','$upassword','$email,'$medic')
^... Here