Help needed with running a mssql_query in other code
Posted: Wed Jan 26, 2011 10:39 am
Hi,
I have an mssql_query function (mssql_query("EXEC [dbo].[update_pr_pulse_flag]");
) on a page that is only there to output values as a csv file. no matter where i put the query however is will not run. i get no error messages...
The query works perfectly in SQL Server and the rest of the code to generate the csv file works fine also.
Any help would be appreciated
S
I have an mssql_query function (mssql_query("EXEC [dbo].[update_pr_pulse_flag]");
) on a page that is only there to output values as a csv file. no matter where i put the query however is will not run. i get no error messages...
Code: Select all
<?php
/*
This file will generate our CSV table. There is nothing to display on this page, it is simply used
to generate our CSV file and then exit. That way we won't be re-directed after pressing the export
to CSV button on the previous page.
*/
//First we'll generate an output variable called out. It'll have all of our text for the CSV file.
$out = '';
//Next we'll check to see if our variables posted and if they did we'll simply append them to out.
if (isset($_POST['csv_hdr'])) {
$out .= $_POST['csv_hdr'];
$out .= "\n";
}
if (isset($_POST['csv_output'])) {
$out .= $_POST['csv_output'];
}
//Now we're ready to create a file. This method generates a filename based on the current date & time.
$filename = $file . date("d-m-Y",time()) . "Pulse";
//Generate the CSV file header
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header("Content-disposition: filename=".$filename.".csv");
//Run the query to update the SentFlag
mssql_query("EXEC [dbo].[update_pr_pulse_flag]");
//Print the contents of out to the generated file.
print $out;
//Exit the script
exit;
?>
Any help would be appreciated
S