php - php页面使用PDO写入mysql的问题
问题描述
如果我直接在 phpmyadmin 中将以下命令作为 SQL 运行,则以下命令有效
CREATE TEMPORARY TABLE tmptable_1 SELECT * FROM De_Lijst WHERE Nieuw = "Ja";
UPDATE tmptable_1 SET DB_ID = NULL, Nieuw = "", Positie =0, Datum_Af = CURRENT_DATE;
INSERT INTO De_Lijst SELECT * FROM tmptable_1;
DROP TEMPORARY TABLE IF EXISTS tmptable_1;
update De_Lijst set Info =if(Nieuw ="Ja","",Info);
update De_Lijst set Datum_Af =if(Nieuw ="Ja","",Datum_Af);
update De_Lijst set Datum_Op =if(Nieuw ="Ja","",Datum_Op);
update De_Lijst set Titel =if(Nieuw ="Ja","",Titel);
update De_Lijst set Artiest =if(Nieuw ="Ja","",Artiest);
update De_Lijst set Nieuw =if(Nieuw ="Ja","",Nieuw);
update De_Lijst set Nieuw =if(Nieuw ="Nieuw","",Nieuw);
我创建了一个名为 reset.php 的页面,看起来像这样
<?php
require 'database.php';
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'update De_Lijst set Info =if(Nieuw ="Ja","nee",Info)';
$q = $pdo->prepare($sql);
$q->execute(array($Nieuw,$Positie,$Artiest,$Titel,$Info,$Datum_Op,$Datum_Af)); 数据库::disconnect();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="./bootstrap-4.0.0/dist /css/bootstrap.min.css">
<link rel="stylesheet" href="./css/custom.css">
<script src="./bootstrap-4.0.0/dist/js/bootstrap.bundle.min.js"> </script>
</head>
<body>
Hello<br>
<form method="POST" action="reset.php">
<input type="submit" name="reset" value="reset"/>
</form>
</body>
</html>
php 文件只是一个查询的测试,但我需要所有的 sql 插入。但会导致 500 错误。关于我做错了什么的任何信息?
谢谢, 雅克
解决方案
推荐阅读
- r - R tryCatch 但在出现警告的情况下保留表达式结果
- android - 如何加密滑翔缓存数据?
- javascript - 导入 Bootstrap 模式后下拉菜单不起作用
- node.js - AWS S3 预签名 POST 访问被拒绝
- excel - 向 EWS 电子邮件添加附件(使用 VBA)
- html - 隐藏在移动设备上的导航栏
- angular - ng-bootstrap Datepicker 默认导航年份为当前日期前 10 年
- c++ - 正在调用 x = std::array
() 与声明 std::array 相同 X? - angular - 在 jhipster 中如何集成角度管理主题模板而不是默认模板
- c# - 使用另一个数据表值更新数据表值