怎么了??为什么不能使用这个SQL?

时间:2014-05-26 05:29:44

标签: php sql database oop insert

为什么这些代码不起作用?

错误:

  

解析错误:语法错误,意外'商品恢复' (T_STRING),   期待'(' in   /Applications/MAMP/htdocs/trip/control/userchoice_control.php在线   275

代码:

    //物価に関しての情報を。コンとローる
    static function commodityrecive () {
            //物価の情報を受け取る
        global $commodityget;
        global $sql10;

        $sql5 = sprintf("SELECT commodity FROM contrydata where destname = '%s'",
                    mysqli_real_escape_string($db,$_POST['destination'])
                );
        $commodityget = mysqli_query($db,$sql5);


        if(isset($commodityget) && $commodityget != ''){
            if(is_numeric($commodityget)){
                addPrice::commoditycost();

            }else{
                error_echo::commodityrecieve_error1();  
            }
        }else{
            error_echo::commodityrecieve_error2();
        }

    }


    //クオリティ情報のレシーブ@コントローラ
    static function qualityrecive(){

        global $qualityget;
        $qualityget = mysqli_query("SELECT quality FROM serviceuser where destname = $_POST['quality']");
            if(isset($qualityget) && $qualityget != ''){    
                if($qualityget === '高級'){//一般&安い
                    return $qualityhigh;
                    addPrice::qualitycost();

                }else if($qualityget === '一般'){
                    return $qualotynomal;
                    addPrice::qualitycost();

                }else if($qalityget === '安い'){
                    return $qualitylow;
                    addPrice::qualitycost();

                }else{
                    error_echo::qualityreceive_error1();
                }
            }else{
                error_echo::qualityrecieve_error2();
            }




    //人数の情報をレシーブ
    static function ninnzuurecive(){


        $ninnzuuget = mysql_query("SELECT numberofpeople FROM serviceuser where destname = $_POST['ninnzuu']");
        if(isset($ninnzuuget) && $ninnzuuget != ''){
            if(is_numeric($ninnzuuget)){
                continue;
            }else{
                error_echo::ninnzuureceive_error1();
            }

            if(2 <= $ninnzuuget <= 9){  

                return $ninnzuuget;
                addPrice::ninnzuuprice();
                //$以下に注意して
            }else{
                error_echo::ninnzuureceive_error2();
            }

        }else{
            error_echo::ninnzuureceive_error3();
        }
    }       



    //プレゼントの有無とかを受信
    static function surprise(){
        $surpriseget = mysql_query("SELECT surprise FROM serviceuser where destname = $_POST['surprise']");
        if(isset($surpriseget) && $surpriseget != ''){
            //正常
            if($surpriseget === 'あり'){
                addPrice::buyPresent();
                addPrice::surpriseSetting();
            }else if($surpriseget === 'なし'){
                //つまりはbirthdayクラスには行かないってこと
                finalCalc::plusCalc();

            }else{
                error_echo::surprise_error1();
            }

        }else{
            //異常
            error_echo::surprise_error2();

        }
    }




    static function ogori(){
        //どんくらい奢るのか計算


        $ogoriget = mysql_query("SELECT ogori FROM serviceuser where ogori = $_POST['ogori']");
        if(isset($ogoriget) && $ogoriget !=''){
            if($ogoriget === '0'){
                $ogorihiritu = 0;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '1'){
                $ogorihiritu = 1;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '1.5'){
                $ogorihiritu = 1.5;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '2'){
                $ogorihiritu = 2;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else{
                error_echo::ogori_error1();
            }
        }else{
            error_echo::ogori_error2();
        }

    }

    static function seasonReceive(){
        $seasonget = mysql_query("SELECT season FROM seriveuser where season = $_POST['season']");
        if(isset($seasonget) && $seasonget != ''){
            if($seasonget === '春' || $seasonget === '秋'){
                 finalCalc::plusCalc();
            }else if($seasonget ==='夏' || $seasonget === '冬'){
                addPrice::seasonPrice();        
            }else{
                error_echo::seasonReceive_error1();
            }

        }else{
            error_echo::seasonReceive_error2();
        }
    }

    static function accidentreceive(){

            $accidentget = mysql_query("SELECT jiko FROM serviceuser where jiko = $_POST['jiko']");

        if(isset($accidentget) && $accidentget != ''){
            if(is_numeric($accidentget) && 1<= strlen($accidentget) <= 2){
                addPrice::accident();
            }else{
                error_echo::accidentreceive_error1();
            }
        }else{
            error_echo::accidentreceive_error2();
        }
    }

}

3 个答案:

答案 0 :(得分:1)

你还没有为第二个功能关闭括号(qualityrecive)     

        $sql5 = sprintf("SELECT commodity FROM contrydata where destname = '%s'",
                    mysqli_real_escape_string($db,$_POST['destination'])
                );
        $commodityget = mysqli_query($db,$sql5);




        if(isset($commodityget) && $commodityget != ''){
            if(is_numeric($commodityget)){
                addPrice::commoditycost();

            }else{
                error_echo::commodityrecieve_error1();  
            }
        }else{
            error_echo::commodityrecieve_error2();
        }

    }


    //クオリティ情報のレシーブ@コントローラ
    static function qualityrecive(){

        global $qualityget;
        $qualityget = mysqli_query("SELECT quality FROM serviceuser where destname = $_POST['quality']");
            if(isset($qualityget) && $qualityget != ''){    
                if($qualityget === '高級'){//一般&安い
                    return $qualityhigh;
                    addPrice::qualitycost();

                }else if($qualityget === '一般'){
                    return $qualotynomal;
                    addPrice::qualitycost();

                }else if($qalityget === '安い'){
                    return $qualitylow;
                    addPrice::qualitycost();

                }else{
                    error_echo::qualityreceive_error1();
                }
            }else{
                error_echo::qualityrecieve_error2();
            }

}


    //人数の情報をレシーブ
    static function ninnzuurecive(){


        $ninnzuuget = mysql_query("SELECT numberofpeople FROM serviceuser where destname = $_POST['ninnzuu']");
        if(isset($ninnzuuget) && $ninnzuuget != ''){
            if(is_numeric($ninnzuuget)){
                continue;
            }else{
                error_echo::ninnzuureceive_error1();
            }

            if(2 <= $ninnzuuget <= 9){  

                return $ninnzuuget;
                addPrice::ninnzuuprice();
                //$以下に注意して
            }else{
                error_echo::ninnzuureceive_error2();
            }

        }else{
            error_echo::ninnzuureceive_error3();
        }
    }       



    //プレゼントの有無とかを受信
    static function surprise(){
        $surpriseget = mysql_query("SELECT surprise FROM serviceuser where destname = $_POST['surprise']");
        if(isset($surpriseget) && $surpriseget != ''){
            //正常
            if($surpriseget === 'あり'){
                addPrice::buyPresent();
                addPrice::surpriseSetting();
            }else if($surpriseget === 'なし'){
                //つまりはbirthdayクラスには行かないってこと
                finalCalc::plusCalc();

            }else{
                error_echo::surprise_error1();
            }

        }else{
            //異常
            error_echo::surprise_error2();

        }
    }




    static function ogori(){
        //どんくらい奢るのか計算


        $ogoriget = mysql_query("SELECT ogori FROM serviceuser where ogori = $_POST['ogori']");
        if(isset($ogoriget) && $ogoriget !=''){
            if($ogoriget === '0'){
                $ogorihiritu = 0;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '1'){
                $ogorihiritu = 1;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '1.5'){
                $ogorihiritu = 1.5;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else if($ogoriget === '2'){
                $ogorihiritu = 2;
                return $ogorihiritu;
                detailCalc::ogoriPrice();

            }else{
                error_echo::ogori_error1();
            }
        }else{
            error_echo::ogori_error2();
        }

    }

    static function seasonReceive(){
        $seasonget = mysql_query("SELECT season FROM seriveuser where season = $_POST['season']");
        if(isset($seasonget) && $seasonget != ''){
            if($seasonget === '春' || $seasonget === '秋'){
                 finalCalc::plusCalc();
            }else if($seasonget ==='夏' || $seasonget === '冬'){
                addPrice::seasonPrice();        
            }else{
                error_echo::seasonReceive_error1();
            }

        }else{
            error_echo::seasonReceive_error2();
        }
    }

    static function accidentreceive(){

            $accidentget = mysql_query("SELECT jiko FROM serviceuser where jiko = $_POST['jiko']");

        if(isset($accidentget) && $accidentget != ''){
            if(is_numeric($accidentget) && 1<= strlen($accidentget) <= 2){
                addPrice::accident();
            }else{
                error_echo::accidentreceive_error1();
            }
        }else{
            error_echo::accidentreceive_error2();
        }
    }
?>

答案 1 :(得分:1)

更改为:

static function choicemove(){ 
    if(isset($_POST['localmove']) && $_POST['localmove'] != ''){
        if($_POST['localmove'] === '自動車'){ 
            addPrice::localcarcost(); 
        }else if($_POST['localmove'] === '電車'){
            addPrice::localtraincost(); 
        }else if($_POST['localmove'] === 'タクシー'){ 
            addPrice::localtaxycost(); 
        }else if($_POST['localmove'] === 'バス'){ 
            addPrice::localbuscost(); 
        }else if($_POST['localmove'] === '高速鉄道(新幹線など)'){ 
            addPrice::localnewlinecost(); 
        }else{ 
            error_echo::choicemove_error2(); 
        } 
    }else{
        error_echo::choicemove_error2();
    } 
}

答案 2 :(得分:1)

在上一个函数choicemove()中你有1个额外的'}':

static function choicemove() { 
    if(isset($_POST['localmove']) && $_POST['localmove'] != '') {   
        if($_POST['localmove'] === '自動車'){ 
            addPrice::localcarcost(); 
        } else if($_POST['localmove'] === '電車') { 
            addPrice::localtraincost(); 
        } else if($_POST['localmove'] === 'タクシー'){ 
            addPrice::localtaxycost(); 
        } else if($_POST['localmove'] === 'バス'){ 
            addPrice::localbuscost(); 
        } else if($_POST['localmove'] === '高速鉄道(新幹線など)'){ 
            addPrice::localnewlinecost(); 
        } else{ 
            error_echo::choicemove_error2(); 
        } 
    } else 
        error_echo::choicemove_error2();
} }

删除最后一个'}'并再次尝试使用您的代码。