I try to run one of the stored proc with php. But somehow this is always display the following error message on the screen:
“Warning: mssql_execute(): supplied argument is not a valid MS SQL-Statement resource…”
Please find below for my code for calling the stored proc in php:
$conn = mssql_connect("sql-02", "rsGreen", "abc123");
$db = mssql_select_db("Green");
$Query = "exec rpt_control @list = '".$_REQUEST['list']."',
@suburb = '".$_REQUEST['suburb']."',
@state = '".$_REQUEST['state']."',
@on_off = ".$_REQUEST['switch'];
mssql_execute($Query );
Do anyone know how is going wrong with my code?
Note: When I’m manually run the stored proc, this is working fine and no error display
mssql_execute()executes a prepared statement, not a string containing a SQL statement (which is the function ofmssql_query(). You will need to prepare a statement, bind parameters into it, and execute it:mssql_execute()docsmssql_bind()docsAlthough it would be possible to execute your stored procedure by building a SQL string and sending it to
mssql_query(), doing so is not recommended when a prepared statement can be used.