无效参数传递给sqlsrv_rows_affected

时间:2017-04-06 23:54:34

标签: php sqlsrv

我又回到了这里。我试图更新SQL Server中的信息,但我一直得到上​​面提到的错误。

这是我的更新代码:

<?php
    $sql = "UPDATE customer
            SET name = (?),
                dobirth = (?),
                cust_sex = (?),
                address  = (?),
                phone = (?),
                mobile = (?),
                id_card =(?),
                ref_no = (?),
                cust_cat = (?),
                internal = (?),
                area_code = (?),
                cust_type = (?),
                group_code = (?),
                group_name = (?),
                dist_code = (?),
                subgroup = (?),
                leader = (?),
                cust_ca2 = (?),
                ntype = (?),
                Children = (?),
                Orphans = (?),
                INCOR_DATE = (?),
                Bank_VNO = (?),
                National_Identity_No = (?),
                Drivers_Liscence_No = (?),
                BVN_No = (?),
                Passport_No = (?),
                Nationality = (?),
                Marital_Status = (?),
                Primary_Address_Line_1 = (?),
                Primary_Address_Line_2 = (?),
                Primary_city_LGA = (?),
                Primary_State = (?),
                Primary_Country = (?),
                Employment_Status = (?),
                Occupation = (?),
                Business_Category = (?),
                Business_Sector  = (?),
                Borrower_Type = (?),
                Other_id = (?),
                Tax_ID = (?),
                Picture_File_Path = (?),
                email_address = (?),
                Employer_Name = (?),
                Employer_Address_Line_1 = (?),
                Employer_Address_Line_2 = (?),
                Employer_City = (?),
                Employer_State  = (?),
                Employer_Country = (?),
                Title = (?),
                Place_of_Birth = (?),
                Work_phone = (?),
                Home_phone = (?),
                E_Secondary_Address_Line_1 = (?),
                E_Secondary_Address_Line_2 = (?),
                E_Secondary_Address_city_LGA = (?),
                Secondary_Address_State = (?),
                Secondary_Address_Country = (?),
                Spouse_Name = (?),
                ***Guarantors_Name = (?),
                Busines_Identification_Number = (?),
                Business_Name = (?),
                Business_Corporate_type = (?),
                cor_Business_Category = (?),
                Date_Of_Incorporation = (?),
                Customer_ID = (?),
                Principal_OfficerSurname = (?),
                Principal_OfficerMIddleName = (?),
                Principal_OfficerFirstname = (?),
                Principal_Officer_National_ID = (?),
                Principal_Officer_BVN_No = (?),
                Principal_Officer_Drivers_Licence = (?),
                Principal_Officer_Passport_No = (?),
                Business_Phone_Number_Line1 = (?),
                Business_Office_Address_Line_1 = (?),
                Business_Office_Address_Line_2 = (?),
                cor_city_LGA = (?),
                cor_State = (?),
                cor_Country = (?),
                cor_Email_address = (?),
                cor_TaxID = (?),
                cor_Secondary_Phone_Number = (?),
                p_Business_Customers_Branch_Code = (?),
                p_Surname = (?),
                p_Firstname = (?),
                p_Middlename = (?),
                p_Date_Of_Birth = (?),
                p_Gender = (?),
                p_Primary_Address_Line_1 = (?),
                p_Primary_Address_Line_2 = (?),
                p_City = (?),
                p_State = (?),
                p_Country = (?),
                p_National_ID = (?),
                p_Drivers_Liscence_No = (?),
                p_BVN_No = (?),
                p_Passport_No = (?),
                p_Phone_No1 = (?),
                p_Email_Address = (?),
                p_Position_in_Business = (?),
                p_PHONE_NO2 = (?),
                p_SECONDARY_ADDRESS = (?),
                p_CITY2 = (?),
                p_STATE2 = (?),
                p_TAX_ID = (?),
                p_PICTURE_FILE_PATH = (?),
                c_Customer_ID = (?),
                c_Account_Status = (?),
                c_Account_status_date = (?),
                c_Date_loan_disbursed_Loan_effective_date = (?),
                c_Credit_limit_Facility_amount_Global_limit = (?),
                c_Loan_Amount_Availed_Limit = (?),
                c_Outstanding_balance = (?),
                c_Instalment_amount = (?),
                c_Currency = (?),
                c_Days_in_arrears = (?),
                c_Overdue_amount = (?),
                c_Loan_type = (?),
                c_Loan_Tenor = (?),
                c_Repayment_frequency = (?),
                c_Last_payment_date = (?),
                c_Last_pay_amount = (?),
                c_Maturity_date = (?),
                c_Branch_code = (?),
                c_Account_number = (?),
                c_Loan_Classification = (?),
                c_Legal_Challenge_Status = (?),
                c_Litigation_Date = (?),
                c_Consent_Status = (?),
                c_Collateral_Status = (?),
                c_Collateral_Type = (?),
                c_Collateral_details = (?),
                c_Previous_Account_number = (?),
                c_Previous_Name = (?),
                c_Previous_Customer_id = (?),
                c_Previous_branch_code = (?),
                c_Guarantors_Phone2 = (?),
                c_Guarantor_Picture_file_path = (?),
                Customer_AccountNo = (?),
                Guarantee_Status = (?),
                GUARANTOR_Surname = (?),
                GUARANTOR_Firstname = (?),
                GUARANTOR_Middlename = (?),
                GUARANTOR_DATE_OF_BIRTH = (?),
                GUARANTOR_GENDER = (?),
                GUARANTOR_National_ID = (?),
                GUARANTOR_Intl_Passport_Number = (?),
                GUARANTOR_Drivers_Licence_Number = (?),
                GUARANTOR_BVN_number = (?),
                GUARANTOR_Other_ID = (?),
                GUARANTOR_PRIMARY_ADDRESS_Line_1 = (?),
                GUARANTOR_PRIMARY_ADDRESS_Line_2 = (?),
                GUARANTOR_PRIMARY_CITY_LGA = (?),
                GUARANTOR_PRIMARY_STATE = (?),
                GUARANTOR_COUNTRY = (?),
                GUARANTOR_Primary_phone_number = (?),
                GUARNTOR_EMAIL_ADDRESS = (?) 
            WHERE branch = '$bran'
              AND cust_no = '$custno'";

    $params = array( $name,
                     $dob,
                     $sex,
                     $addr,
                     $phone,
                     $mobile,
                     $id_card,
                     $ref,
                     $cust_cat,
                     $internal,
                     $acode,
                     $cust_type,
                     $gcode,
                     $gname,
                     $dcode,
                     $sgroup,
                     $leader,
                     $cust_ca2,
                     $ntype,
                     $child,
                     $ophan,
                     $incor,
                     $bank_vno,
                     $nin,
                     $dln,
                     $bvn,
                     $pass_no,
                     $nat,
                     $marital,
                     $pal1,
                     $pad2,
                     $plg,
                     $ps,
                     $pc,
                     $es,
                     $occup,
                     $bc,
                     $bs,
                     $bt,
                     $oi,
                     $ti,
                     $filePath,
                     $ea,
                     $en,
                     $eal1,
                     $eal2,
                     $ec,
                     $est,
                     $econ,
                     $title,
                     $pob,
                     $wp,
                     $hp,
                     $esal1,
                     $esal2,
                     $esac,
                     $sas,
                     $sac,
                     $sn,
                     $gnn,
                     $bin,
                     $bn,
                     $bct,
                     $cbc,
                     $doi,
                     $ci,
                     $posN,
                     $pomn,
                     $pofn,
                     $poni,
                     $pobvn,
                     $podn,
                     $popn,
                     $bpnl,
                     $boal1,
                     $boal2,
                     $ccl,
                     $cs,
                     $cc,
                     $cea,
                     $ct,
                     $cspn,
                     $pbcbc,
                     $psn,
                     $pfn,
                     $pmn,
                     $pdob,
                     $pg,
                     $ppal1,
                     $ppal2,
                     $pcity,
                     $pstate,
                     $pcon,
                     $pni,
                     $pdln,
                     $pbvn,
                     $ppn,
                     $ppn1,
                     $pea,
                     $ppib,
                     $ppn2,
                     $psa,
                     $pcity2,
                     $pstate2,
                     $pti,
                     $fileName3,
                     $ccid,
                     $cas,
                     $casd,
                     $cdldled,
                     $cclfagl,
                     $claal,
                     $cob,
                     $cia,
                     $ccur,
                     $cdia,
                     $coa,
                     $clt,
                     $cltenor,
                     $crf,
                     $clpd,
                     $clpa,
                     $cmd,
                     $cbcode,
                     $can,
                     $clc,
                     $clcs,
                     $cld,
                     $ccs,
                     $ccols,
                     $cct,
                     $ccd,
                     $cpan,
                     $cpn,
                     $cpci,
                     $cpbc,
                     $cgp2,
                     $fileName2,
                     $cano,
                     $gs,
                     $gsn,
                     $gfn,
                     $gmn,
                     $gdb,
                     $gg,
                     $gni,
                     $gipn,
                     $gdln,
                     $gbvn,
                     $goi,
                     $gpal1,
                     $gpal2,
                     $gps,
                     $gpst,
                     $gc,
                     $gppn,
                     $gea 
                   );

    $stmt = sqlsrv_query( $conn, $sql, $params );

    $rows_affected = @sqlsrv_rows_affected( $stmt );

    if( $rows_affected === false) {
         die( print_r( sqlsrv_errors(), true) );
    } elseif( $rows_affected == -1 ) {
        echo '<div class = "alert-warning" id = "alert_message">Error: update failed.  Try again.</div>';
    } else {
        echo '<div class="alert-success" id="alert_message">Successfully Updated.<br /></div>';
        @header("refresh:1;update"); // refresh after 1 second.
    }
?>

请其他程序员,您认为可能是错误的原因。

1 个答案:

答案 0 :(得分:0)

我查看了您的代码并发现了一些潜在的拼写错误。这些是 -

  • 在某些地方,您使用Guarantor,而在其他地方使用。{li> Guarantors。您应该检查每个字段是否确实存在 拼写正确。我没有改变这些字段的名称 在我的答案中,因为我假设它们拼写正确。
  • SQL的最后一个字段拼写为GUARNTOR_EMAIL_ADDRESS。所有 其他字段使用Guarantor(在各种框中)我假设 这是一个拼写错误,并相应地更新了我的答案。
  • 您的一个变量拼写为$ophan。因为这符合 字段Orphans,我假设这是拼写错误的 $orphan$orphans。我选择在我的中使用前者 答案。

以下是按照以上几点编辑的代码副本......

<?php
    $sql = "UPDATE customer
            SET name = (?),
                dobirth = (?),
                cust_sex = (?),
                address  = (?),
                phone = (?),
                mobile = (?),
                id_card =(?),
                ref_no = (?),
                cust_cat = (?),
                internal = (?),
                area_code = (?),
                cust_type = (?),
                group_code = (?),
                group_name = (?),
                dist_code = (?),
                subgroup = (?),
                leader = (?),
                cust_ca2 = (?),
                ntype = (?),
                Children = (?),
                Orphans = (?),
                INCOR_DATE = (?),
                Bank_VNO = (?),
                National_Identity_No = (?),
                Drivers_Liscence_No = (?),
                BVN_No = (?),
                Passport_No = (?),
                Nationality = (?),
                Marital_Status = (?),
                Primary_Address_Line_1 = (?),
                Primary_Address_Line_2 = (?),
                Primary_city_LGA = (?),
                Primary_State = (?),
                Primary_Country = (?),
                Employment_Status = (?),
                Occupation = (?),
                Business_Category = (?),
                Business_Sector  = (?),
                Borrower_Type = (?),
                Other_id = (?),
                Tax_ID = (?),
                Picture_File_Path = (?),
                email_address = (?),
                Employer_Name = (?),
                Employer_Address_Line_1 = (?),
                Employer_Address_Line_2 = (?),
                Employer_City = (?),
                Employer_State  = (?),
                Employer_Country = (?),
                Title = (?),
                Place_of_Birth = (?),
                Work_phone = (?),
                Home_phone = (?),
                E_Secondary_Address_Line_1 = (?),
                E_Secondary_Address_Line_2 = (?),
                E_Secondary_Address_city_LGA = (?),
                Secondary_Address_State = (?),
                Secondary_Address_Country = (?),
                Spouse_Name = (?),
                Guarantors_Name = (?),
                Busines_Identification_Number = (?),
                Business_Name = (?),
                Business_Corporate_type = (?),
                cor_Business_Category = (?),
                Date_Of_Incorporation = (?),
                Customer_ID = (?),
                Principal_OfficerSurname = (?),
                Principal_OfficerMIddleName = (?),
                Principal_OfficerFirstname = (?),
                Principal_Officer_National_ID = (?),
                Principal_Officer_BVN_No = (?),
                Principal_Officer_Drivers_Licence = (?),
                Principal_Officer_Passport_No = (?),
                Business_Phone_Number_Line1 = (?),
                Business_Office_Address_Line_1 = (?),
                Business_Office_Address_Line_2 = (?),
                cor_city_LGA = (?),
                cor_State = (?),
                cor_Country = (?),
                cor_Email_address = (?),
                cor_TaxID = (?),
                cor_Secondary_Phone_Number = (?),
                p_Business_Customers_Branch_Code = (?),
                p_Surname = (?),
                p_Firstname = (?),
                p_Middlename = (?),
                p_Date_Of_Birth = (?),
                p_Gender = (?),
                p_Primary_Address_Line_1 = (?),
                p_Primary_Address_Line_2 = (?),
                p_City = (?),
                p_State = (?),
                p_Country = (?),
                p_National_ID = (?),
                p_Drivers_Liscence_No = (?),
                p_BVN_No = (?),
                p_Passport_No = (?),
                p_Phone_No1 = (?),
                p_Email_Address = (?),
                p_Position_in_Business = (?),
                p_PHONE_NO2 = (?),
                p_SECONDARY_ADDRESS = (?),
                p_CITY2 = (?),
                p_STATE2 = (?),
                p_TAX_ID = (?),
                p_PICTURE_FILE_PATH = (?),
                c_Customer_ID = (?),
                c_Account_Status = (?),
                c_Account_status_date = (?),
                c_Date_loan_disbursed_Loan_effective_date = (?),
                c_Credit_limit_Facility_amount_Global_limit = (?),
                c_Loan_Amount_Availed_Limit = (?),
                c_Outstanding_balance = (?),
                c_Instalment_amount = (?),
                c_Currency = (?),
                c_Days_in_arrears = (?),
                c_Overdue_amount = (?),
                c_Loan_type = (?),
                c_Loan_Tenor = (?),
                c_Repayment_frequency = (?),
                c_Last_payment_date = (?),
                c_Last_pay_amount = (?),
                c_Maturity_date = (?),
                c_Branch_code = (?),
                c_Account_number = (?),
                c_Loan_Classification = (?),
                c_Legal_Challenge_Status = (?),
                c_Litigation_Date = (?),
                c_Consent_Status = (?),
                c_Collateral_Status = (?),
                c_Collateral_Type = (?),
                c_Collateral_details = (?),
                c_Previous_Account_number = (?),
                c_Previous_Name = (?),
                c_Previous_Customer_id = (?),
                c_Previous_branch_code = (?),
                c_Guarantors_Phone2 = (?),
                c_Guarantor_Picture_file_path = (?),
                Customer_AccountNo = (?),
                Guarantee_Status = (?),
                GUARANTOR_Surname = (?),
                GUARANTOR_Firstname = (?),
                GUARANTOR_Middlename = (?),
                GUARANTOR_DATE_OF_BIRTH = (?),
                GUARANTOR_GENDER = (?),
                GUARANTOR_National_ID = (?),
                GUARANTOR_Intl_Passport_Number = (?),
                GUARANTOR_Drivers_Licence_Number = (?),
                GUARANTOR_BVN_number = (?),
                GUARANTOR_Other_ID = (?),
                GUARANTOR_PRIMARY_ADDRESS_Line_1 = (?),
                GUARANTOR_PRIMARY_ADDRESS_Line_2 = (?),
                GUARANTOR_PRIMARY_CITY_LGA = (?),
                GUARANTOR_PRIMARY_STATE = (?),
                GUARANTOR_COUNTRY = (?),
                GUARANTOR_Primary_phone_number = (?),
                GUARANTOR_EMAIL_ADDRESS = (?) 
            WHERE branch = '$bran'
              AND cust_no = '$custno'";

    $params = array( $name,
                     $dob,
                     $sex,
                     $addr,
                     $phone,
                     $mobile,
                     $id_card,
                     $ref,
                     $cust_cat,
                     $internal,
                     $acode,
                     $cust_type,
                     $gcode,
                     $gname,
                     $dcode,
                     $sgroup,
                     $leader,
                     $cust_ca2,
                     $ntype,
                     $child,
                     $orphan,
                     $incor,
                     $bank_vno,
                     $nin,
                     $dln,
                     $bvn,
                     $pass_no,
                     $nat,
                     $marital,
                     $pal1,
                     $pad2,
                     $plg,
                     $ps,
                     $pc,
                     $es,
                     $occup,
                     $bc,
                     $bs,
                     $bt,
                     $oi,
                     $ti,
                     $filePath,
                     $ea,
                     $en,
                     $eal1,
                     $eal2,
                     $ec,
                     $est,
                     $econ,
                     $title,
                     $pob,
                     $wp,
                     $hp,
                     $esal1,
                     $esal2,
                     $esac,
                     $sas,
                     $sac,
                     $sn,
                     $gnn,
                     $bin,
                     $bn,
                     $bct,
                     $cbc,
                     $doi,
                     $ci,
                     $posN,
                     $pomn,
                     $pofn,
                     $poni,
                     $pobvn,
                     $podn,
                     $popn,
                     $bpnl,
                     $boal1,
                     $boal2,
                     $ccl,
                     $cs,
                     $cc,
                     $cea,
                     $ct,
                     $cspn,
                     $pbcbc,
                     $psn,
                     $pfn,
                     $pmn,
                     $pdob,
                     $pg,
                     $ppal1,
                     $ppal2,
                     $pcity,
                     $pstate,
                     $pcon,
                     $pni,
                     $pdln,
                     $pbvn,
                     $ppn,
                     $ppn1,
                     $pea,
                     $ppib,
                     $ppn2,
                     $psa,
                     $pcity2,
                     $pstate2,
                     $pti,
                     $fileName3,
                     $ccid,
                     $cas,
                     $casd,
                     $cdldled,
                     $cclfagl,
                     $claal,
                     $cob,
                     $cia,
                     $ccur,
                     $cdia,
                     $coa,
                     $clt,
                     $cltenor,
                     $crf,
                     $clpd,
                     $clpa,
                     $cmd,
                     $cbcode,
                     $can,
                     $clc,
                     $clcs,
                     $cld,
                     $ccs,
                     $ccols,
                     $cct,
                     $ccd,
                     $cpan,
                     $cpn,
                     $cpci,
                     $cpbc,
                     $cgp2,
                     $fileName2,
                     $cano,
                     $gs,
                     $gsn,
                     $gfn,
                     $gmn,
                     $gdb,
                     $gg,
                     $gni,
                     $gipn,
                     $gdln,
                     $gbvn,
                     $goi,
                     $gpal1,
                     $gpal2,
                     $gps,
                     $gpst,
                     $gc,
                     $gppn,
                     $gea 
                   );

    $stmt = sqlsrv_query( $conn, $sql, $params );

    $rows_affected = @sqlsrv_rows_affected( $stmt );

    if( $rows_affected === false)
    {
         die( print_r( sqlsrv_errors(), true) );
    }
    elseif( $rows_affected == -1 )
    {
        echo '<div class = "alert-warning" id = "alert_message">Error: update failed.  Try again.</div>';
    }
    else
    {
        echo '<div class="alert-success" id="alert_message">Successfully Updated.<br /></div>';
        @header("refresh:1;update"); // refresh after 1 second.
    }
?>

如果您有任何问题或意见,请随时发表评论。