我遇到以下错误:
“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在'Not,Fotograf,Tarih'附近使用正确的语法('','','',''' ,'','','','TC','','','','Ev'在第1行“
(我正在使用不断询问“mysqli”的wamp6.4)
有什么不对?
$ekle = mysql_query("INSERT INTO kayitliste (AdayNo, KimlikNo, Ad, Soyad, MezunLise, DiplomaDerece, TelefonNo, Uyruk, VeliAdSoyad, VeliTelefon, Adres, Ulasim, Bolge, Yurt, Bolum, TercihSirasi, Burs, Dekont, Kimlik, Diploma, Odenen, Sinif, Not, Fotograf, Tarih)
VALUES ('$AdayNo','$KimlikNo','$Ad','$Soyad','$MezunLise','$DiplomaDerece','$TelefonNo','$Uyruk','$VeliAdSoyad','$VeliTelefon','$Adres','$Ulasim','$Bolge','$Yurt','$Bolum','$TercihSirasi','$Burs','$Dekont','$Kimlik','$Diploma','$Odenen','$Sinif','$Not','$Fotograf','$Tarih') ");
答案 0 :(得分:2)
mysqli
已弃用。您应该使用参数化查询PDO
或$link = mysqli_connect("localhost", "root", "");
mysqli_select_db("Your database");
if ($stmt = mysqli_prepare($link, "INSERT INTO `kayitliste` VALUES (?, ?, ?, ?, ?)")) {
/* bind parameters for markers */
mysqli_stmt_bind_param($stmt, $type, $AdayNo, $KimlikNo, $Ad, $Soyad, $MezunLise);
/* Execute query */
mysqli_stmt_execute($stmt);
/* Bind result variables */
mysqli_stmt_bind_result($stmt, $AdayNo, $KimlikNo, $Ad, $Soyad, $MezunLise);
/* Close statement */
mysqli_stmt_close($stmt);
}
,如下所示:
$type
"s"
可以是"i"
表示字符串,"d"
表示整数,"b"
表示双倍,?
表示blob。
问号$type = "iisss"
必须与要插入数据库的值一样多。
在您拥有多个值的情况下,您应该知道每个值的类型并写入No
,并使用与您的值一样多的字母。由于您的变量使用的语言我不知道我发现integers
中的结尾是strings
而其他三个$sql = 'INSERT INTO `kayitliste` (`AdayNo`, `KimlikNo`, `Ad`, `Soyad`, `MezunListe`)
VALUES (:AdayNo, :KimlikNo, :Ad, :Soyad, :MezunListe)';
$sth = $dbh->prepare($sql);
$sth->bindParam(':AdayNo', $AdayNo, PDO::PARAM_INT);
/* Do that for every parameter */
/* PDO::PARAM_INT is the equivalent of "i" of mysqli in PDO. */
$sth->execute()
。
password_hash
答案 1 :(得分:1)
在这种情况下,查看自己生成的查询会很有帮助。这样做:
echo "insert into kayitliste (AdayNo, KimlikNo, Ad, Soyad, MezunLise, DiplomaDerece, TelefonNo, Uyruk, VeliAdSoyad, VeliTelefon, Adres, Ulasim, Bolge, Yurt, Bolum, TercihSirasi, Burs, Dekont, Kimlik, Diploma, Odenen, Sinif, Not, Fotograf, Tarih)
values
('$AdayNo','$KimlikNo','$Ad','$Soyad','$MezunLise','$DiplomaDerece','$TelefonNo','$Uyruk','$VeliAdSoyad','$VeliTelefon','$Adres','$Ulasim','$Bolge','$Yurt','$Bolum','$TercihSirasi','$Burs','$Dekont','$Kimlik','$Diploma','$Odenen','$Sinif','$Not','$Fotograf','$Tarih') ";
然后检查生成的查询。我敢打赌,如果你仔细看,你会发现你的错误。