MySQLi bind_param()不起作用

时间:2015-11-29 16:37:07

标签: php mysql mysqli bindparam

我对MySQLi的PHP bind_param函数有一个相当奇怪的问题。

我用?' s创建查询,其中参数将被绑定,我准备语句,绑定参数然后执行语句。由于某种原因,它没有绑定参数。该系统是原型招聘软件,用于更新注册申请人的详细信息。

以下是代码:

$query = "UPDATE Applicants SET University_College='?', Notice_Period='?', Wanting_To_Leave='?', Reason_Leaving='?', Interviews_Arranged='?', Companies_To_Contact='?', Like_To_Work_For='?', Applicant_Division='?', Applicant_First_Name='?', Applicant_Last_Name='?', T_P_C='?', Applicant_Phone_Number='?', Applicant_Mobile='?', Applicant_Email='?', Applicant_Current_Company='?', Applicant_Current_Job_Title='?', Applicant_Current_Salary='?', Applicant_Miles_To_Work='?', Applicant_Consultants_ID='?', Applicant_Title='?', Applicant_DOU=NOW(), Applicant_Industry='?', Applicant_Languages='?', Applicant_Employment_Status='?', Applicant_Advert='?', Applicant_Town='?', Applicant_Country='?', Applicant_Address='?', Applicant_Postcode='?', Applicant_Qualification_Level='?', Applicant_Qualification_Field='?', Applicant_Notice_Period='?', CV_Text='?' WHERE Applicant_ID='?' ";

    $stmt = $con->prepare($query);
    $stmt->bind_param("ssssssssssssssssssisssssssssssssi", $UniversityCollege, $NoticePeriod, $WantingToLeave, $ReasonLeaving, $InterviewsArranged, $CompaniesToContact, $LikeToWorkFor, $ApplicantDivision, $ApplicantFirstName, $ApplicantLastName, $TPC, $ApplicantPhoneNumber, $ApplicantMobile, $ApplicantEmail, $ApplicantCurrentCompany, $ApplicantCurrentJob, $ApplicantCurrentSalary, $ApplicantMilesToWork, $ConsultantsID, $ApplicantTitle, $ApplicantIndustry, $ApplicantLanguages, $ApplicantEmploymentStatus, $ApplicantAdvert, $ApplicantTown, $ApplicantCountry, $ApplicantAddress, $ApplicantPostcode, $ApplicantQualificationLevel, $ApplicantQualificationField, $ApplicantNoticePeriod, $CVText, $ApplicantID);

    $stmt->execute() or die("Something went wrong, could not update applicant :-(");  

    printf("%d Row inserted.\n", $stmt->affected_rows);                     

非常感谢任何帮助!

非常感谢!

1 个答案:

答案 0 :(得分:2)

'?'表示带有一个符号?的字符串。 占位符只是?

$query = "UPDATE Applicants SET University_College=?, Notice_Period=?...