这是怎么回事:
function del_lc() {
let la = $('#sela option:selected').text().toLowerCase();
let lb = $('.lbact').text();
let lc = $('.lcact').text();
let lcid = $('.lcact').attr('data-id');
let story = $('#storytxt').val();
var fn = 'del_lc';
$.post('index-pro.php', {la, lb, lc, lcid, story, fn}, function(data) {
console.log(data);
});
}
php
extract($_POST);
$sql = "insert into rec (what, la, lb, lc, story) values (:awhat, :ala, :alb, :alc, :astory)";
$st = $db->prepare($sql);
$st->execute(array(
":awhat" => 'lc',
":ala" => $_POST['la'],
":alb" => $_POST['lb'],
":alc" => $_POST['lc'],
":story" => $_POST['story'] // line 184
));
$sql = "delete from lc where id = :aid";
$st = $db->prepare($sql);
$st->execute(array(
":aid" => $_POST['lcid']
));
Fatal error - Invalid parameter number: parameter was not defined in D:\code\s00\index-pro.php:184
。
有帮助吗?
答案 0 :(得分:0)
您在第184行出错了,请改用以下代码:
extract($_POST);
$sql = "insert into rec (what, la, lb, lc, story) values (:awhat, :ala, :alb, :alc, :astory)";
$st = $db->prepare($sql);
$st->execute(array(
":awhat" => 'lc',
":ala" => $_POST['la'],
":alb" => $_POST['lb'],
":alc" => $_POST['lc'],
":astory" => $_POST['story'] // line 184
));
$sql = "delete from lc where id = :aid";
$st = $db->prepare($sql);
$st->execute(array(
":aid" => $_POST['lcid']
));