这里有什么问题:
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
。有什么帮助吗?
最佳答案
您在第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']
));