Reputation: 3903
My PHP skills are rusty. I am trying to execute a stored procedure with the following code
<?php
$server = “SQLINSTANCE”;
$options = array( "UID" => “uname”, "PWD" => “password, "Database" => "HomeSensors");
$conn = sqlsrv_connect($server, $options);
if ($conn === false)
die("<pre>".print_r(sqlsrv_errors(), true));
echo "Successfully connected!<br/>";
$stmt = mssql_init('addSensorData', $conn);
mssql_bind($stmt, '@Pool', 90, SQLINT1, false, false, 3);
mssql_bind($stmt, '@Temp', 80, SQLINT1, false, false, 3);
$proc_result = mssql_execute($stmt);
if( $proc_result === false) {
die( print_r( sqlsrv_errors(), true) );
}
mssql_free_statement($stmt);
?>
When I execute the following, the server response is:
Successfully connected!
But nothing is executed and I don't see any errors. What am I doing wrong?
Upvotes: 1
Views: 72
Reputation: 92854
Use mssql_connect
at first.
What kind of result does your procedure have to return(one or many result sets)?
Also try mssql_query
instead of mssql_init
function.
Approximate approach:
$result = mssql_query("addSensorData Var1, Var2, Var3...");
$arr = mssql_fetch_row($result);
Upvotes: 1