Nuke Toolbar

          
Quick Links 
 [Home Page ][ Category Listings ][ Forum Listings][ Forum FAQs]
[ HomeDNS - Domains ]  [ Nuke Resources ]  [ Nuke Skins and Themes ]  [ Nuke Sites Link Directory ]
[ LearningLinux.com ]  [ Nuke Fixes ]
[ NukeZone Hosting ]
Nuke Forums Forum Index

Nuke Sites Link Directory


exporting nuke_users data

 
Post new topic   Reply to topic    Nuke Forums Forum Index -> MySQL - Installation, Programming Etc.
View previous topic :: View next topic  
Author Message
zettie
Corporal
Corporal


Joined: 15 Dec 2003
Posts: 15


PostPosted: Mon Dec 15, 2003 7:03 am    Post subject: exporting nuke_users data Reply with quote

I'm really hoping someone might be able to help me with a problem I'm having...

I have discovered a problem where several (hundreds) of our users were added through the edit user screen and ended up with a space (or in some cases 2 spaces) inserted before the email address and other fields. My bulk emails are coming through, but I'm not able to effectively search or sort users because of this space.

I would like to export the data to an excel csv sheet, delete the extraneous spaces and import the data back into the nuke_user portion of the database.

Now, I confess, I am a newbie, I am NOT a programmer. I do not have the slightest idea how to program in sql. With that said, I have 3 questions...

If I export the nuke_users data through MyAdmin as a CSV for MS Excel file, does it export a "copy" of the data? I want to make sure I'm not "removing" the actual data. I also didn't notice a field where I enter the path where the exported data will reside when complete.

Second question, after I modify the data in excel (assuming I can do this), how do I go about importing it back into MyAdmin?

Third question, I cannot find nuke_users in my ftp program, I have to access it through lunarpages/cpanel. Is there a better way to do this?

Thank you in advance for any help you can give me!!

Suzette Bergeron
www.skytoyz.com
Back to top
View user's profile Send private message Visit poster's website
zettie
Corporal
Corporal


Joined: 15 Dec 2003
Posts: 15


PostPosted: Mon Jan 05, 2004 11:22 am    Post subject: Reply with quote

Maybe I'm going about this wrong, but I entered the code below using notepad, called it email.php, uploaded it to my server and pointed my browser to it. First I got a parse error on line 15. I tried deleting the ", then I got a parse error on line 18. Now I'm stuck.

Is there a specific place where I should upload this to my site and is it ok to ftp it?

I'm finally getting over the holiday madness and getting ready to clean up my data. Any help would be greatly appreciated!!

Suzette
www.skytoyz.com
Back to top
View user's profile Send private message Visit poster's website
chris
President
President


Joined: 06 Nov 2002
Posts: 1047
Location: Outer Space

PostPosted: Mon Jan 05, 2004 1:38 pm    Post subject: Reply with quote

First of all use a decent text editor.

Second, the above code mixes the old and the new SQL layer. Try this one:

Code:

<?php

include("mainfile.php");
global $prefix, $db, $dbi;

$sql = "SELECT * FROM ".$prefix."_users ORDER BY user_id ASC";
$result = $db->sql_query($sql);
WHILE ($row = $db->sql_fetchrow($result)) {

$userid = $row['user_id'];
$oldemail = $row["user_email"];
$newemail = str_replace (" ","",$oldemail);

$update = $db->sql_query("UPDATE ".$prefix."_users set user_email='$newemail' where user_id='$userid'");

}
?>


Always make a backup of your database before trying such a thing! If it breaks, you keep both pieces.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zettie
Corporal
Corporal


Joined: 15 Dec 2003
Posts: 15


PostPosted: Tue Jan 06, 2004 5:20 am    Post subject: Reply with quote

Thanks! When you say use a decent text editor, what should I use? I thought notepad would be the safest bet.

Also, what would be the best way to back up my data? I know how to do a full backup of my site, but not sure how to just back up the nuke users. Can I export through cpanel and if so, does it export a "copy" and (one more thing) how do you import the .xls if I should need to?

Thanks again for all your help!!!
Back to top
View user's profile Send private message Visit poster's website
chris
President
President


Joined: 06 Nov 2002
Posts: 1047
Location: Outer Space

PostPosted: Tue Jan 06, 2004 5:53 pm    Post subject: Reply with quote

Before we continue, I have a question:

Did the above block, as I posted it, solve your problem?

It is important to know, not only for me, but for anyone who might have the same problem.

O.K., for your other questions:

Notepad & Co.: Did you follow my link? If so, then you know that Notepad and Wordpad may introduce invisible characters that lead to errors with PHP.

The situation arises then, when a user comes in a Forum and says: "My PHP is complaining that there is an error on line XY".

We search for the error a few days....till we notice that it was some invisible character somewhere (most of the time at the end of the line).

To backup a single table, I think there is an option for this in phpMyAdmin. Anyway, you can always backup all tables, then open the backup file and delete everything up to those lines that have to do with your table. You will recognize them, because they are preceded with comments like:

Code:

#
# Table structure for table `nuke_users`
#


for the structure of the nuke_users table and:

Code:

#
# Dumping data for table `nuke_users`
#


for its data.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zettie
Corporal
Corporal


Joined: 15 Dec 2003
Posts: 15


PostPosted: Wed Jan 07, 2004 8:54 am    Post subject: Reply with quote

To answer your question simply, no, I have not resolved this issue as of yet. I did not notice the link about the text editor before but I just downloaded one of the more friendly editors (crimson) and pasted your code there.

I tried to ftp it to my site, but I received this error:

Warning: main(mainfile.php): failed to open stream: No such file or directory in /home/skytoyz2/public_html/a_UPLOADS/user2.php on line 3

Warning: main(): Failed opening 'mainfile.php' for inclusion (include_path='.:/home/skytoyz2/public_html/oscommerce/') in /home/skytoyz2/public_html/a_UPLOADS/user2.php on line 3

Fatal error: Call to a member function on a non-object in /home/skytoyz2/public_html/a_UPLOADS/user2.php on line 7

Is there a specific place where I should upload this file? Perhaps I am in over my head but I would really like to try to figure out a simpler way to take these spaces out without going into every single record and deleting them manually

Thank you for your help and patience

Suzette
Back to top
View user's profile Send private message Visit poster's website
chris
President
President


Joined: 06 Nov 2002
Posts: 1047
Location: Outer Space

PostPosted: Sun Jan 11, 2004 7:37 am    Post subject: Reply with quote

I'm late in answering this - and I will go offline after this post, so you may be on your own...

Where did you upload the file?

You should put it in the directory where also the mainfile.php of your PHP-Nuke is located.

Look at what that poor file I gave you does: it includes "mainfile.php".

What does "mainfile.php" mean? It a relative filename, meaning that the file is in the same folder you script is executing. So if you put your script in

Code:

/home/skytoyz2/public_html/a_UPLOADS/


then PHP is told to include "mainfile.php" and understands:

Code:

Include /home/skytoyz2/public_html/a_UPLOADS/mainfile.php


tries to find it, does NOT find it - and issues an error message saying exactly that:

Code:

Warning: main(): Failed opening 'mainfile.php' for inclusion (include_path='.:/home/skytoyz2/public_html/oscommerce/') in /home/skytoyz2/public_html/a_UPLOADS/user2.php on line 3


How on earth is your PHP going to include it if it is not there? So put that file in the same folder as mainfile.php.

Or change "mainfile.php" (a relative filename, meaning that the file is in the same folder you script is executing), to the full path of mainfile.php on your server.

I find the first solution much easier (and it will probably be the correct one, because mainfile.php will in turn try to include "config.php" and may not find it if your script is executing from a different dir).

Make a backup of your database before you try it!

I wish you good luck - and don't forget to tell us how it went. I will come back.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zettie
Corporal
Corporal


Joined: 15 Dec 2003
Posts: 15


PostPosted: Mon Jan 12, 2004 6:41 am    Post subject: Reply with quote

YES! It worked! Thank you so much. I not only had spaces in the email field, but also in the username and name fields so I modified the code to make these adjustments and my data is now all cleaned up and looking good. This is immensely helpful as I can now check for duplicates (my sorting was all messed up due to the spaces).

Thank you again!!

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Nuke Forums Forum Index -> MySQL - Installation, Programming Etc. All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group




Forum Options
Main Menu
index.php?sid=2cfaf660165a2837a98ef92f80becd6aForums Index
    - Collaped View
    + Expanded View
FAQFAQ
SearchSearch
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesLog in to check your private messages
Log inLog in

Visitor Options
 
Subscribe
Unsubscribe


Keep informed of updates, bug fixes, software releases, news and more!
Installation or Upgrade Services for phpNuke or PostNuke? Require site maintenance, addons, modules or custom themes? Send private message or e-mail for rates and availablity.

Quick Links
  Domain Names
  Firewall Forums
  Joke Crazy
  Learning Linux
  Find your IP Fast!
  Purchase WinRAR

Trusted Nuke Sites
  NukeZone Hosting
  NukeFixes.com
  NukeResources.com
  NukeSkins.com
  NukeSites.com
  PHPNuke.org

Sponsor Links


NukeZone Hosting