Author Topic: Export Emails to csv  (Read 18867 times)

0 Members and 1 Guest are viewing this topic.

Offline Knuty

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Export Emails to csv
« Reply #15 on: February 16, 2006, 07:44:38 PM »
Working perfect like a norwegian girl :)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Export Emails to csv
« Reply #16 on: February 16, 2006, 07:51:12 PM »
Quote

a norwegian girl


Now, that's one good example. :mrgreen:

Offline Brainwrek

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Export Emails to csv
« Reply #17 on: August 23, 2006, 11:02:11 PM »
This looks OUTSTANDING!

I would like to modify it to retrieve all sender & recipient email addresses from the ecards.  I tried the following code, but it crashes out.

Code: [Select]
<?php // PLUGIN_TITLE: Ecard Emails

$nozip 1;
define('IN_CP'1);
define('ROOT_PATH'"./../../");
define('ROOT_PATH_ADMIN'"./../");
require(
ROOT_PATH_ADMIN.'admin_global.php');

show_admin_header();

$anzahl 0

$sql "SELECT ".get_user_table_field("""postcard_recipient_email"). get_user_table_field(", ""postcard_sender_email")."
FROM "
.POSTCARDS_TABLE."";
//WHERE user_allowemails = '1'"; 

$result $site_db->query($sql);
$anz $site_db->get_numrows($result); 

if (
$anz) {

$fp = @fopen('all-ecard-addresses/list.csv''w+'); 

while (
$sql_array $site_db->fetch_array($resultMYSQL_NUM)) { 
$text implode(' ; '$sql_array) . " ; \n"
@
fwrite ($fp$text); 
###### End of while statement.

@fclose($fp); 

echo 
"<a href=\"".$site_sess->url(ROOT_PATH_ADMIN."plugins/all-ecard-addresses/list.csv")."\">".$lang['download']."</a>";

###### End of if statement.

show_admin_footer();
?>

The error for the above code is:
Quote
DB Error: Bad SQL Query: SELECT FROM 4users
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM 4users' at line 2

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/stick/public_html/ecards/includes/db_mysql.php on line 116

Still investigating, but would appreciate any help you could provide.  Thanks!!!

Special thanks to TheOracle!
« Last Edit: August 23, 2006, 11:12:54 PM by Brainwrek »

Offline Brainwrek

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Export Emails to csv
« Reply #18 on: August 23, 2006, 11:14:31 PM »
This looks OUTSTANDING!

I would like to modify it to retrieve all sender & recipient email addresses from the ecards.  I tried the following code, but it crashes out.

Code: [Select]
<?php // PLUGIN_TITLE: Ecard Emails

$nozip 1;
define('IN_CP'1);
define('ROOT_PATH'"./../../");
define('ROOT_PATH_ADMIN'"./../");
require(
ROOT_PATH_ADMIN.'admin_global.php');

show_admin_header();

$anzahl 0

$sql "SELECT ".get_user_table_field("""postcard_recipient_email"). get_user_table_field(", ""postcard_sender_email")."
FROM "
.POSTCARDS_TABLE."";
//WHERE user_allowemails = '1'"; 

$result $site_db->query($sql);
$anz $site_db->get_numrows($result); 

if (
$anz) {

$fp = @fopen('all-ecard-addresses/list.csv''w+'); 

while (
$sql_array $site_db->fetch_array($resultMYSQL_NUM)) { 
$text implode(' ; '$sql_array) . " ; \n"
@
fwrite ($fp$text); 
###### End of while statement.

@fclose($fp); 

echo 
"<a href=\"".$site_sess->url(ROOT_PATH_ADMIN."plugins/all-ecard-addresses/list.csv")."\">".$lang['download']."</a>";

###### End of if statement.

show_admin_footer();
?>

The error for the above code is:
Quote
DB Error: Bad SQL Query: SELECT FROM 4postcards
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM 4postcards' at line 2

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/stick/public_html/ecards/includes/db_mysql.php on line 116

Still investigating, but would appreciate any help you could provide.  Thanks!!!

Special thanks to TheOracle!

Offline Brainwrek

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Export Emails to csv
« Reply #19 on: August 24, 2006, 07:34:37 AM »
Ok...

With valuable help from TheOracle (thank you!), this is working very well for extracting the emails from ecards.  Here's the code I'm using:
Code: [Select]
<?php // PLUGIN_TITLE: Ecard Emails

$nozip 1;
define('IN_CP'1);
define('ROOT_PATH'"./../../");
define('ROOT_PATH_ADMIN'"./../");
require(
ROOT_PATH_ADMIN.'admin_global.php');

show_admin_header();

$anzahl 0

$sql "SELECT postcard_recipient_email, postcard_sender_email
FROM "
.POSTCARDS_TABLE."";

$result $site_db->query($sql);
$anz $site_db->get_numrows($result); 

if (
$anz) {

$fp = @fopen('addresses/emails.csv''w+'); 

while (
$sql_array $site_db->fetch_array($resultMYSQL_NUM)) { 
$text implode("," $sql_array) . ","
$list str_replace("," "\n" $text);
@
fwrite ($fp$list); 
###### End of while statement.

@fclose($fp); 

echo 
"<a href=\"".$site_sess->url(ROOT_PATH_ADMIN."plugins/addresses/emails.csv")."\">Download</a>";

###### End of if statement.

show_admin_footer();
?>