1

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?

1

1 Answer 1

1
+50

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.