Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Ventic on March 18, 2012, 10:19:51 AM

Title: member emails
Post by: Ventic on March 18, 2012, 10:19:51 AM
its possible to take all my members email in one txt?
Title: Re: member emails
Post by: pkrack on March 18, 2012, 10:36:41 AM
Your all members email are stored in mysql database. So you can get them from there directly. Or you can use a simple code like <?php include("settings.php")
$sql=("SELECT * Smf_members");
$get=mysql_fetch_array($sql);
$email=$get[member_email]
$fn "file.txt";
$file fopen($fn"a+");
$size filesize($fn);
$space.= "\n";
fwrite($file$get;
$text fread($file,
$size);
fwrite ($file$space);
fclose($file);
?>

The above code can add your emails to a text file. Although it is not perfect but some one here will fix the bugs and tables names if wrong.
Title: Re: member emails
Post by: Ventic on March 18, 2012, 10:39:53 AM
i am waiting :)
Title: Re: member emails
Post by: Ventic on March 19, 2012, 07:36:18 AM
bump
Title: Re: member emails
Post by: wesleydeman on March 19, 2012, 03:08:51 PM
Quote from: Ventic on March 18, 2012, 10:19:51 AM
its possible to take all my members email in one txt?

Go to your phpmyadmin where your forum database is stored.
Then go to your database then to your table called smf_members or members.
Then click SQL at the top of the page.
In the text area put this: SELECT email_address FROM smf_members
Then click on go, and then you will see the result with al the email addresses then click on Export at the bottom of the page in the Query results operations options.
Then as Export Method you choose custom.
At Rows you choose all rows.
At Output choose View output as text.
At Format choose SQL.
At Format-specific options choose by Dump table choose Data.
And then click on go.
Then under INSERT INTO `smf_members` (`email_address`) VALUES
You will see all the email addresses.
Title: Re: member emails
Post by: pkrack on March 19, 2012, 11:10:47 PM
That method is easy but i posted that code because he wants an automated system in which emails are directly added to a file
Title: Re: member emails
Post by: wesleydeman on March 20, 2012, 04:44:38 AM
Quote from: pkrack on March 19, 2012, 11:10:47 PM
That method is easy but i posted that code because he wants an automated system in which emails are directly added to a file

its possible to take all my members email in one txt?.

He didden't say automatic he just wanted all member emails in text.
Title: Re: member emails
Post by: Ventic on March 21, 2012, 10:20:31 AM
i need automatic a way to export them in a txt :D
Title: Re: member emails
Post by: Ventic on March 22, 2012, 01:52:53 AM
Quote from: Ventic on March 21, 2012, 10:20:31 AM
i need automatic a way to export them in a txt :D
Title: Re: member emails
Post by: pkrack on March 22, 2012, 03:34:02 AM
The code i have posted will do automatic addition of emails. But you just need to fix the name of variable , tables and column as i am very busy now days coding a mobile toplist so i have no time to check the the smf tables. (sorry for that)
Title: Re: member emails
Post by: Ventic on March 22, 2012, 08:07:01 AM
Quote from: pkrack on March 22, 2012, 03:34:02 AM
The code i have posted will do automatic addition of emails. But you just need to fix the name of variable , tables and column as i am very busy now days coding a mobile toplist so i have no time to check the the smf tables. (sorry for that)
no problem,so i will make that php file,add it in my /forum folder and just link with it for example gaming-paradise.net/forum/email.php?
Title: Re: member emails
Post by: pkrack on March 22, 2012, 09:22:17 AM
Yeah. That all (but fixing the names of table is required). You can also pm me the link if you got error while running the file.
Title: Re: member emails
Post by: pkrack on March 23, 2012, 01:01:00 AM
Some lines which were missing.so i edited it.
<?php include("settings.php");
connect($db_sever,$db_name,$db_user,$db_password);
$sql=mysql_Query("SELECT * from Smf_members");
$get=mysql_fetch_array($sql);
$email=$get[member_email]

//adding emails to textfile
$fn "file.txt";
$file fopen($fn"a+");
$size filesize($fn);
$space.= "\n";
fwrite($file$get;
$text fread($file,
$size);
fwrite ($file$space);
fclose($file);
?>

try this code. I havent connected to database. Also fix the members email column name from data base here
Title: Re: member emails
Post by: Ventic on March 23, 2012, 06:45:26 AM
connect($db_sever,$db_name,$db_user,$db_password);
should add my details?
Title: Re: member emails
Post by: Ventic on March 23, 2012, 06:47:22 AM
still the same white page
Title: Re: member emails
Post by: pkrack on March 23, 2012, 08:52:16 AM
It will give white page as i havent echoed any text. But have you checked the file(file.txt)? Moreover the file must be rewriteable. I.e  should be chmod to 666
Title: Re: member emails
Post by: Ventic on March 23, 2012, 01:07:29 PM
Quote from: Ventic on March 23, 2012, 06:45:26 AM
connect($db_sever,$db_name,$db_user,$db_password);
should add my details?
Title: Re: member emails
Post by: pkrack on March 23, 2012, 01:44:46 PM
No its already added in settings.php which i included.
Title: Re: member emails
Post by: Ventic on March 23, 2012, 03:18:24 PM
still same ******
Title: Re: member emails
Post by: Kindred on March 23, 2012, 03:35:42 PM
wow...   impatient, aren't you?

Yes, you will always just get a white screen because there's no echoed text...
Did you look for the file called file.txt on your server? Is it there?

if you insist on having something on your screen, then add an echo
(and I heartily recommend learning some basic coding)


<?php include("settings.php");
echo 
'connecting to database... ('$db_sever '  -  ' $db_name ')';
connect($db_sever,$db_name,$db_user,$db_password);
$sql=mysql_Query("SELECT * from Smf_members");
$get=mysql_fetch_array($sql);
$email=$get[member_email];

echo 
' adding emails to textfile';
//adding emails to textfile
$fn "file.txt";
$file fopen($fn"a+");
$size filesize($fn);
$space.= "\n";
fwrite($file$get);
$text fread($file$size);
fwrite ($file$space);
fclose($file);
echo 
'file created:' $file;
?>



BTW pkrack, nice code... but I think you missed a closing parens in the first fwrite line...
Title: Re: member emails
Post by: pkrack on March 23, 2012, 11:51:04 PM
@Kindred thanks for comments. Actually i am very busy now days in writing code for a mobile search engine toplist due to which i wrote this code roughly. And thanks for fixing it. :-)
Title: Re: member emails
Post by: Ventic on March 24, 2012, 07:14:47 AM
Internal Server Error now i got this damn
Title: Re: member emails
Post by: pkrack on March 24, 2012, 07:30:04 AM
           You mean 500 internal error. Does your host support .txt files? Some server do not support that and can possibly cause an error.
           Some time php also cause error with looping but this code isnt repeating. I think i have to test it on my own server
Title: Re: member emails
Post by: Ventic on March 24, 2012, 01:33:24 PM
it accept txt files yes
Title: Re: member emails
Post by: pkrack on March 25, 2012, 01:00:39 AM

<?php include("Settings.php");

$conn=@mysql_connect($db_server,$db_user,$db_pass);
if(!
$conn)return false;
$db=@mysql_select_db($db_name);
if(!
$db)return false;
return 
true;

$sql=mysql_Query("SELECT * from Smf_members");
$get=mysql_fetch_array($sql);
$email=$get[email_address];

echo 
' adding emails to textfile';
//adding emails to textfile
$fn "file.txt";
$file fopen($fn"a+");
$size filesize($fn);
$space.= "\n";
fwrite($file$get);
$text fread($file$size);
fwrite ($file$space);
fclose($file);
?>



now test it, i have uploaded it at hitcross.tk/a.php and is giving no error.
Title: Re: member emails
Post by: Ventic on March 26, 2012, 04:23:42 PM
still didnt worked to me

shall i give you in pm my smf_members file and send me later the file with mails?