我无法在数据库中插入记录,我得到的错误是您的SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在“添加,用户ID,用户名,密码”附近使用正确的语法VALUES('swapnil','this','74125894630','this @gmail.com'在第1行
无法弄清楚此错误的用途。
<?php
$host="localhost";
$user="kunwaraabid567";
$pass="Myuniverse159";
$db="tradehug";
$conn=mysqli_connect($host,$user,$pass);
if($conn){
echo "";
}else{
echo "connection error";
}
$select=mysqli_select_db($conn,$db) or die(mysqli_error($conn));
if(isset($_POST['submit'])){
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];
$city=$_POST['city'];
$add=$_POST['add'];
$userid=$_POST['userid'];
$username=$_POST['username'];
$password=$_POST['password'];
$query1="SELECT username FROM assoc WHERE username='$username'";
$check1=mysqli_query($conn,$query1) or die(mysqli_error($conn));
if(mysqli_num_rows($check1)>=1)
{
echo"name already exists";
}
else
{
$query="INSERT INTO assoc (fname,lname,mobile,email,city,add,userid,username,password) VALUES('$fname','$lname','$mobile','$email','$city','$add','$userid','$username','$password') ";
$check=mysqli_query($conn,$query) or die(mysqli_error($conn));
if($check){
header('Location: dashboard.php');
}
}
}
?>
答案 0 :(得分:0)
版本问题试试这个: - 添加“`”,包含所有字段名称和表名`assoc`
INSERT INTO for each_topic in range(num_topics):
a = tw['word_prob_pair'].iloc[each_topic]
for word, prob in a:
topic_.set_value(each_topic, word, prob)
(assoc
,fname
,lname
,mobile
,email
,city
,{{1 },add
,userid
)VALUES('$ fname','$ lname','$ mobile','$ email','$ city','$ add','$ userid ','$ username','$ password')“;
答案 1 :(得分:0)
得到了答案,
我使用的add是mysql中的reserve关键字,这就是显示错误的原因。
答案 2 :(得分:-1)
尝试将您的表名从assoc更改为其他名称。 Assoc在php中意味着很多东西。
将插入语句更改为
$query= mysqli_query("INSERT INTO assoc (fname,lname,mobile,email,city,add,userid,username,password) VALUES('$fname','$lname','$mobile','$email','$city','$add','$userid','$username','$password') ");
希望这有效