简体   繁体   English

PHP / mysql我的代码有什么问题,它将插入到错误的列中

[英]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... 您要将4个参数传递给orderInsert因此您的数据有偏斜...

Either remove SESSION['userSession'] from your call to orderInsert or add a corresponding field to the database table, and accept it in your function. 从对orderInsert的调用中删除SESSION['userSession']或向数据库表中添加一个相应的字段,然后在您的函数中接受它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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