这是代码
<?php
$a=$_POST['A'];
$B=$_POST['B'];
$c=$_POST['C'];
$d=$_POST['Z'];
$e=$_POST['o'];
$link = mysqli_connect('localhost', 'root', '123');
$db_selected = mysqli_select_db($link,'makler1');
echo mysqli_error($link);
if(isset($_POST['Murad'])){
// Create connection
if (!$db_selected) {
die ('aa ' . mysqli_error());
}else{
echo"a";
}
$ip = ip2long($ip);
$sqlb = " INSERT INTO makler1 ('a','b','c','d','e')
VALUES ('$a', '$B', '$c', '$d', '$e')";
if(!mysqli_query($link,$sqlb)){
echo mysqli_error($link);
}
mysqli_close($link);
}
?>
<html>
<input Placeholder="Username" name="A"><p></p>
<input Placeholder="Komnati" name="B"><p></p>
<input Placeholder="kv/m" name="C"><p></p>
<input Placeholder="Cena" name="Z"><p></p>
<input Placeholder="Arenda" name="o"><p></p>
<form method="post"><input type="submit" name="Murad" id="tester" value="Register" title="Register" onMouseOut="backbg()" onMouseOver="changebg()" ></form></html>
它给出错误“您的SQL语法中有错误;请查看与您的MySQL服务器版本对应的手册,以便在”a“,”b“,”c“,”d“附近使用正确的语法, 'e')VALUES('','','','','')'在第1行“
答案 0 :(得分:0)
不要在a,b,c,d,e
使用引号。
$sqlb = " INSERT INTO makler1 (a,b,c,d,e)
VALUES ('$a', '$B', '$c', '$d', '$e')";