duanlu7680 2015-11-29 16:37
浏览 49
已采纳

MySQLi bind_param()不起作用

I have a rather odd issue with the PHP bind_param function for MySQLi.

I create the query with ?'s where the parameters will be bound, I prepare the statement, I bind the parameters and then I execute the statement. For some reason it is not binding the parameters. The system is a prototype recruitment software and this is used to update the details for a registered applicant.

Here is the code:

$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.
", $stmt->affected_rows);                     

Any help is much appreciated!

Thanks a lot!

  • 写回答

1条回答 默认 最新

  • dongle0396 2015-11-29 16:39
    关注

    '?' means a string with one symbol ?. Placeholder is just ?:

    $query = "UPDATE Applicants SET University_College=?, Notice_Period=?...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示