RE: [PHP-DB] Save mySQL data into a CSV file.
Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { What did I do wrong? Thanks Martin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 5:42 PM To: Martin E. Koss Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Save mySQL data into a CSV file. $qry = SELECT * FROM TABLE_NAME; $result_set = mysql_query($qry) or die(mysql_error()); ***this has to be called before any headers are written to the browser. *** header(Content-type: application/csv); header(Content-Disposition: attachement; filename=YOURFILENAME.csv); while ($record_set_array = each($result_set)) { print implode(,, $record_set_array) . \n; } that should pretty much cover it. hth Jeff Martin E. Koss [EMAIL PROTECTED]To: [EMAIL PROTECTED] ows.com cc: Subject: RE: [PHP-DB] Save mySQL data into a CSV file. 06/16/2003 12:22 PM I've heard or read about the headers somewhere but right now I sure could use pointing in the direction of a step-by-step tutorial for extracting my data into a CSV file and, of course, setting up the PHP file to handle it correctly. Thanks Martin -Original Message- From: Dillon, John [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 2:06 PM To: 'Martin E. Koss' Subject: RE: [PHP-DB] Save mySQL data into a CSV file. It's something to do with the header in the html page. -Original Message- From: Martin E. Koss [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 13:53 To: Subject: [PHP-DB] Save mySQL data into a CSV file. Importance: High Hi, I have a table with 1,008 columns in it and at it's peak it has up to 500 rows of data. I want to enable my client to click on a link and the next thing they are prompted with is 'Save or Open' (the CSV file). The data will be compiled into a comma delimited CSV file but rather than be printed to the screen it would be best if the browser popped up asking where to save the 'filename.csv' file to. Once saved, the file can be opened in Excel for analysis. Where do I start to do this? Thanks Martin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Save mySQL data into a CSV file.
do a var_dump($result_set) to see what $result_set contains (if it's actually and array. (did you implement the code given as is? if not AND you have put line-11 in a function and $result_set as a global variable then you need to define $result_set as a global inside the function.) ramil On Tue, 2003-06-17 at 14:16, Martin E. Koss wrote: Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { What did I do wrong? Thanks Martin -Original Message- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Save mySQL data into a CSV file.
On Tuesday 17 June 2003 14:16, Martin E. Koss wrote: Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { $result_set = mysql_query($qry) or die(mysql_error()); Because $result_set is a resource id. Refer to the examples in the manual on how to get results from a db. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Good day for overcoming obstacles. Try a steeplechase. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Save mySQL data into a CSV file.
I've heard or read about the headers somewhere but right now I sure could use pointing in the direction of a step-by-step tutorial for extracting my data into a CSV file and, of course, setting up the PHP file to handle it correctly. Thanks Martin -Original Message- From: Dillon, John [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 2:06 PM To: 'Martin E. Koss' Subject: RE: [PHP-DB] Save mySQL data into a CSV file. It's something to do with the header in the html page. -Original Message- From: Martin E. Koss [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 13:53 To: Subject: [PHP-DB] Save mySQL data into a CSV file. Importance: High Hi, I have a table with 1,008 columns in it and at it's peak it has up to 500 rows of data. I want to enable my client to click on a link and the next thing they are prompted with is 'Save or Open' (the CSV file). The data will be compiled into a comma delimited CSV file but rather than be printed to the screen it would be best if the browser popped up asking where to save the 'filename.csv' file to. Once saved, the file can be opened in Excel for analysis. Where do I start to do this? Thanks Martin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Save mySQL data into a CSV file.
$qry = SELECT * FROM TABLE_NAME; $result_set = mysql_query($qry) or die(mysql_error()); ***this has to be called before any headers are written to the browser. *** header(Content-type: application/csv); header(Content-Disposition: attachement; filename=YOURFILENAME.csv); while ($record_set_array = each($result_set)) { print implode(,, $record_set_array) . \n; } that should pretty much cover it. hth Jeff Martin E. Koss [EMAIL PROTECTED]To: [EMAIL PROTECTED] ows.com cc: Subject: RE: [PHP-DB] Save mySQL data into a CSV file. 06/16/2003 12:22 PM I've heard or read about the headers somewhere but right now I sure could use pointing in the direction of a step-by-step tutorial for extracting my data into a CSV file and, of course, setting up the PHP file to handle it correctly. Thanks Martin -Original Message- From: Dillon, John [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 2:06 PM To: 'Martin E. Koss' Subject: RE: [PHP-DB] Save mySQL data into a CSV file. It's something to do with the header in the html page. -Original Message- From: Martin E. Koss [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 13:53 To: Subject: [PHP-DB] Save mySQL data into a CSV file. Importance: High Hi, I have a table with 1,008 columns in it and at it's peak it has up to 500 rows of data. I want to enable my client to click on a link and the next thing they are prompted with is 'Save or Open' (the CSV file). The data will be compiled into a comma delimited CSV file but rather than be printed to the screen it would be best if the browser popped up asking where to save the 'filename.csv' file to. Once saved, the file can be opened in Excel for analysis. Where do I start to do this? Thanks Martin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php