php - MySQL 查询不正确
问题描述
我不知道为什么以下 MySQL Query 一直失败。它告诉我它的语法无效。它总是在代码的电子邮件区域显示,但没有明显的错误。在将字符串传递到 MySQL 查询之前,我正在清理它们
$query = "INSERT INTO `ToReview` (`number`, `role`, `name`, `email`, `dob`,
`englishskills`, `previousmember`, `reasonYes`, `whyjoin`,
`whatcouldyoubring`, `roleplayexperience`, `roleplayexperiencedetail`,
`commit`, `minimumperiod`) VALUES (NULL, ".$role.", ".$name.", ".$email.",
".$dob.", ".$englishskills.", ".$previousmember.", ".$reasonYes.",
".$whyjoin.", ".$whatcouldyoubring.", ".$roleplayexperience.",
".$roleplayexperiencedetail.", ".$commit.", ".$minimumperiod.");";
$result = mysqli_query($con, $query) or die(mysqli_error($con));
解决方案
您正在结束分号处关闭双引号,删除它并重试
$query = "INSERT INTO `ToReview` (`number`, `role`, `name`, `email`, `dob`,
`englishskills`, `previousmember`, `reasonYes`, `whyjoin`,
`whatcouldyoubring`, `roleplayexperience`, `roleplayexperiencedetail`,
`commit`, `minimumperiod`) VALUES (NULL, '$role', '$name', '$email',
'$dob','$englishskills', '$previousmember', '$reasonYes',
'$whyjoin', '$whatcouldyoubring', '$roleplayexperience',
'$roleplayexperiencedetail', '$commit', '$minimumperiod')";
推荐阅读
- python - 函数 process_frame(input_frame) 如何接收它的参数?
- c - Lua C API:将指针作为用户数据推送
- java - Android:将数据从 ViewPager2 和 TabLayout 管理的片段发送到包含的活动
- json-ld - 在本地服务器上测试时 rdflib 无效的远程上下文
- java - 如何安装和忘记 java 9 模块(在 Windows 上)?
- linux - grep 文件以读取键:值
- c++ - 将构造函数的参数复制到智能指针中
- javascript - 制作成功的 AR 标记是否有任何既定规则/要求?
- java - 带有 SOAP XML JAX-WS(WAS Portal 7)服务的 Java 1.6 Maven 项目到 Tomcat Liferay 6.2 GA6 无法访问端点
- node.js - PM2 说可执行文件“出错”但没有正确重新启动它;仍需手动重启