简体   繁体   中英

PHP/mysql what's wrong with my code, it inserts to the wrong column

class.user.php
    public function orderInsert($servicetype,$templateselection,$orderdetails)
{
    try
    {       
    $stmt = $this->conn->prepare("INSERT INTO tbl_order(TypeofService,TemplateSelect,orderdetails) 
                                                VALUES(:Service_Type, :Template_Select, :order_details)");                                      

    $stmt->bindparam(":Service_Type",$servicetype);
    $stmt->bindparam(":Template_Select",$templateselection);
    $stmt->bindparam(":order_details",$orderdetails);
    $stmt->execute(); 
    return $stmt;
    }
    catch(PDOException $ex)
    {
        echo $ex->getMessage();
    }
}


userTrans.php

        if($activity == "OrderInsert")
                {
                    $TypeofService = $_POST[TypeofService];
                    $TemplateSelect = $_POST[TemplateSelect]; 
                    $orderdetails = $_POST[orderdetails];





                    if($user_home->OrderInsert($_SESSION[userSession],$TypeofService,$TemplateSelect,$order_details))
                    {
                        echo response(1,'Inserting '.$TypeofService.' Order, success!',0);
                    }else{
                        echo response(0,'Inserting '.$TypeofService.' Order, failed!',0);
                    }

                }

Result:

You're passing 4 arguments to orderInsert so your data is skewed...

Either remove SESSION['userSession'] from your call to orderInsert or add a corresponding field to the database table, and accept it in your function.

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