SQL查询中的数组;PHP
这是我编写的一个查询,用于将数据插入MYSQL数据库。但是,每次执行时,我都会收到这个错误消息 错误:无法执行sql。您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解第1行“Handbook 2019.pdf,'备注'”(mysql:host=localhost;dbname=test,$user,$pass)附近使用的正确语法; $stmt=$dbh->prepare(“将结果(用户id、序列号、状态、续约日期、到期日期、证据1、备注)插入社会合规性文档列表中”)值(:用户id、:序列号、:状态、:续约日期、:到期日期、:备注”); $stmt->bindParam(':user\u id',$user\u id); $stmt->bindParam(':serial_number',$row['ID']); $stmt->bindParam(':status',$status_数组[$index]); $stmt->bindParam(':date\u of_renewal',$date\u of_renewal\u数组[$index]); $stmt->bindParam(':date\u of_expiry',$date\u of_expiry\u数组[$index]); $stmt->bindParam(':证据1',$证据); $stmt->bindParam(':remarks',$remark_数组[$index]); $stmt->execute();SQL查询中的数组;PHP,php,mysql,Php,Mysql,这是我编写的一个查询,用于将数据插入MYSQL数据库。但是,每次执行时,我都会收到这个错误消息 错误:无法执行sql。您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解第1行“Handbook 2019.pdf,'备注'”(mysql:host=localhost;dbname=test,$user,$pass)附近使用的正确语法; $stmt=$dbh->prepare(“将结果(用户id、序列号、状态、续约日期、到期日期、证据1、备注)插入社会合规性文档列表中”)值
这基本上就是您需要的,未经测试,只是从PHP文档中快速拼凑而成。具体而言,.您的问题几乎肯定是要插入的字符串中存在单引号。与使用字符串连接(这会产生SQL注入漏洞)构建查询不同,使用with。有关一些好的示例,请参见和。
$insert_document_list_results = "insert into social_compliance_document_list_results
(user_id, serial_number, status, date_of_renewal, date_of_expiry, evidence_1, remarks)
values($user_id, {$row['ID']}, $status_array[$index], $date_of_renewal_array[$index], $date_of_expiry_array[$index], $evidence, $remark_array[$index])";