I have a php/mysql site which also connects to an mssql database to run some stored procedures. There is a form that asks for postcode, distance from postcode and returns effectively the stores within that distance of the postcode. For some reason when this function is run and there are no results the form returns correctly with a message saying no results found. If there are results for some reason the browser soft redirects back to the homepage. If I comment out the mssql_execute part of the function the redirect doesnt happen, obviously I get no results. When I put the mssql_execute in and run the same request the page is redirected. The function with the stored procedure execution is below.
function getCompaniesByAddress(){
global $msdb;
//initiate function
$proc = mssql_init('usp_Search_Scope_And_Range', $msdb);
//Load Parameters
mssql_bind($proc, '@SuperscopeID', $_POST['activity'], SQLINT4, false, false, 10);
mssql_bind($proc, '@ScopeID', $_POST['scheme'], SQLINT4, false, false, 10);
mssql_bind($proc, '@PCode', $_POST['postcode'], SQLVARCHAR, false, false, 10);
mssql_bind($proc, '@Distance', $_POST['distance'], SQLINT4, false, false, 10);
try
{
$result = mssql_execute($proc);
//If the exception is thrown, this text will not be shown
}
//catch exception
catch(Exception $e)
{
echo 'Message: ' .$e->getMessage();
}
//Execute Procedure
//$result = mssql_execute($proc);
//Free Memory
mssql_free_statement($proc);
while ($row = mssql_fetch_assoc($result))
$results[] = $row;
$res = array_chunk(sortDataSet($results,'Mileage_FL'),20);
return $res[0];
}