0
votes

Error message:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in /home/u410366608/public_html/admin/items.php:210 Stack trace: #0 /home/u410366608/public_html/admin/items.php(210): PDOStatement->execute(Array) #1 {main} thrown in /home/u410366608/public_html/admin/items.php on line 210

code:

                if (empty($formErrors)) {

                    $stmt = $con->prepare("INSERT INTO items(Namea, Descriptiona, Pricea, Add_Datea, Country_Madea, Statusa, Cat_IDa, Member_IDa)
                    VALUES(:zname, :zdesc, :zprice, now(), :zcountry, :zstatus, :zcat, :member)");

                    $stmt->execute(array(

                        'zname'     => $name,
                        'zdesc'     => $desc,
                        'zprice'    => $price,
                        'zcountry'  => $country,
                        'zstatus'   => $status,
                        'zcat'      =>$cat,
                        'zmember'   =>$member

                    ));

                    echo "<div class='container'>";
                    $theMsg = "<div class='alert alert-success'>" . $stmt->rowCount() . 'Preke prideta.</div>';
                    redirectHome($theMsg, 'back' );
                    echo "</div>";      
                }
2
:member should be :zmember - e4c5

2 Answers

0
votes

Use this code array and change :zmember instead of :member

if (empty($formErrors)) {

    $stmt = $con->prepare("INSERT INTO items(Namea, Descriptiona, Pricea, Add_Datea, Country_Madea, Statusa, Cat_IDa, Member_IDa)
         VALUES(:zname, :zdesc, :zprice, now(), :zcountry, :zstatus, :zcat, :zmember)");

    $stmt->execute(array(
        ':zname'     => $name,
        ':zdesc'     => $desc,
        ':zprice'    => $price,
        ':zcountry'  => $country,
        ':zstatus'   => $status,
        ':zcat'      =>$cat,
        ':zmember'   =>$member
    ));

    echo "<div class='container'>";
    $theMsg = "<div class='alert alert-success'>" . $stmt->rowCount() . 'Preke prideta.</div>';
    redirectHome($theMsg, 'back' );
    echo "</div>";      
}
0
votes

in your statement you used :member and in the associative array you used

'zmember' =>$member , change 'zmember' =>$member to 'member' =>$member this will fix the problem.