简体   繁体   中英

Invalid parameter number: parameter was not defined error pdo

$txtmemberid = $_POST['txtmemberid'];
$txtname = $_POST['txtname'];
$txtphoneno = $_POST['txtphoneno'];
$txtmembertype = $_POST['txtmembertype'];

$query = "insert into member(member_id, name, ph_no, member_type) values(:member_id, :name, :ph_no, :member_type)";

try{
    $stmt = $conn -> prepare($query);

    $stmt -> bindParam(':member_id', $txtmemberid);
    $stmt -> bindParam(': name', $txtname);
    $stmt -> bindParam(':ph_no', $txtphoneno);
    $stmt -> bindParam(':member_type', $txtmembertype);

    $stmt -> execute();
}

Your problem is more than likely on this line:

$stmt -> bindParam(': name',$txtname);

You have extraneous whitespace between : and name , change it to this:

$stmt -> bindParam(':name',$txtname);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM