jquery ajax-参数号无效

ldioqlga  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(351)

这里有什么问题:

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` .
有什么帮助吗?
f2uvfpb9

f2uvfpb91#

您在第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']
));

相关问题