member emails

Started by Ventic, March 18, 2012, 10:19:51 AM

Previous topic - Next topic

Ventic

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

pkrack

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.

Ventic


Ventic


wesleydeman

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.

pkrack

That method is easy but i posted that code because he wants an automated system in which emails are directly added to a file

wesleydeman

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.

Ventic

i need automatic a way to export them in a txt :D

Ventic


pkrack

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)

Ventic

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?

pkrack

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.

pkrack

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

Ventic

connect($db_sever,$db_name,$db_user,$db_password);
should add my details?

Ventic

still the same white page

pkrack

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

Ventic

Quote from: Ventic on March 23, 2012, 06:45:26 AM
connect($db_sever,$db_name,$db_user,$db_password);
should add my details?

pkrack

No its already added in settings.php which i included.

Ventic


Kindred

#19
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...
Слова
Украина

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

pkrack

@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. :-)

Ventic

Internal Server Error now i got this damn

pkrack

           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

Ventic

it accept txt files yes

pkrack


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

Ventic

still didnt worked to me

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

Advertisement: