My problem most likely stems from me not understanding how to properly work with MSSQL result sets and arrays, but here goes. I've got a form that compiles a query based on the information provided. I've written a function that executes the query and spews out the data in a table.
At the end of the page, I want to have an option to send that data to a spreadsheet. I've gotten that to work just fine by sending the query to my create_spreadsheet.php page, but I'm trying to avoid hitting the database twice for the same amount of information.
If I understand correctly, I should be able to use the result set from the function that creates the table and send that over to my create_spreadsheet.php page and skip hitting the database again. $rs is the variable that contains the result set. Now, I may not properly understand variable scope either, but I declared $rs as global before the function as well as within the function so that I may use it elsewhere. I did some googling after realizing POST won't handle sending a big result set like that, so I decided to try using sessions.
This is on the primary page:
Code: Select all
session_start();
$_SESSION['resultset'] = $rs;
echo "<TD>";
echo "</FORM><form action=\"create_spreadsheet.php\" method=\"POST\">";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"action\" value=\"Create Spreadsheet\">";
echo "</TD></FORM>";Code: Select all
Warning: mssql_num_fields(): supplied argument is not a valid MS SQL-result resource in /var/www/html/reports/8-function.inc on line 255
Warning: mssql_fetch_row(): supplied argument is not a valid MS SQL-result resource in /var/www/html/reports/8-function.inc on line 262Thanks ahead of time for any help!