SQL 语法错误:找不到 [英] SQL syntax error: can't be found
本文介绍了SQL 语法错误:找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 SQL 新手,所以我可能遗漏了一些东西.显然我在这一行有一个语法错误:
I'm new to SQL so i'm probably missing something. Apparently I have a syntax error on this line:
$mysql = 'INSERT INTO Orders (Name, Recipient, Destination, Room, Message, Anonymous, OffCampus, OffCampusAddress) VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
谁能帮我找出我做错了什么?提前致谢
Could anyone help me identify what I am doing wrong? Thanks in advance
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的?, ?, ?, ?, ?, ?, ?, ?)"附近使用的正确语法
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?, ?, ?, ?, ?, ?, ?)' at line 1
这是我的参数绑定:
mysqli_stmt_bind_param($stmt, 'ssssssss', $name, $recipient, $destination, $room, $message, $anonymous, $offcampus, $offcampusaddress);
推荐答案
它应该是这样的:
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'world');
$mysql = "INSERT INTO Orders\n" +
"(Name, Recipient, Destination, Room, Message, Anonymous, OffCampus, OffCampusAddress)\n" +
"VALUES\n" +
"(?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($link, $mysql);
mysqli_stmt_bind_param($stmt, 'ssssssss', $name, $recipient, $destination, $room, $message, $anonymous, $offcampus, $offcampusaddress);
mysqli_stmt_execute($stmt);
这篇关于SQL 语法错误:找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文