Help needed with running a mssql_query in other code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sunegtheoverlord
Forum Commoner
Posts: 28
Joined: Thu Feb 18, 2010 5:02 am

Help needed with running a mssql_query in other code

Post by sunegtheoverlord »

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...

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;



?>
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
User avatar
sunegtheoverlord
Forum Commoner
Posts: 28
Joined: Thu Feb 18, 2010 5:02 am

Re: Help needed with running a mssql_query in other code

Post by sunegtheoverlord »

Why is programming so infuriating?!

i had neglected to include a connection to the database....


AAARGRGHH£"$*£"$(*($£*

Sorry for the complete waste of your time if you're reading this!

:banghead:
Post Reply