Php cannot execute the mssql stored procedure.

Source: Internet
Author: User
When php calls the mssql stored procedure, it cannot execute the problematic stored procedure. what is the problem?
Require (".. /inc/hbmconn. php "); // input the vip name $ name = iconv (" UTF-8 "," gb2312 ", $ _ REQUEST ['name']); $ startTime =" 2012-04-01 "; $ endTime = "2012-04-03"; $ procedure = mssql_init ("procGetVIPConsumeDetail", $ conn); mssql_bind ($ procedure, "@ vipConsumerFilter", $ name, SQLVARCHAR ); mssql_bind ($ procedure, "@ startDate", $ startTime, SQLDATETIME); mssql_bind ($ procedure, "@ endDate", $ endTime, SQLDATETIME ); $ resource = mssql_execute ($ procedure); mssql_free_statement ($ procedure );


It cannot be executed. I don't know what the situation is. let's take a look.


Reply to discussion (solution)

Echo mssql_get_last_message ();
Check whether there are any error messages.

Echo mssql_get_last_message ();
Check whether there are any error messages.

The constant SQLDATETIME is not defined.
Check whether your writing is correct.
You can also print_r (get_defined_constants ());
Check whether similar constants exist.

The meaning of the last error message is unclear. maybe the date format is incorrect.

// Input the vip name $ name = iconv ("UTF-8", "gb2312", $ _ REQUEST ['name']); // echo $ name; $ startTime = "1970-01-01"; $ endTime = date ("H-m-d"); $ procedure = mssql_init ("procGetVIPConsumeDetail", $ conn); mssql_bind ($ procedure, "@ vipConsumerFilter", $ name, SQLVARCHAR); mssql_bind ($ procedure, "@ startDate", $ startTime, SQLVARCHAR); mssql_bind ($ procedure, "@ endDate", $ endTime, SQLVARCHAR); $ resource = mssql_execute ($ procedure); mssql_free_statement ($ procedure );



Replace the date with the SQLVARCHAR format. this is all you need!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.