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!