11
planetexcel
Re: Is there a query to add users in a batch?

I believe also the passwords was not imported..

12
Burning
Re: Is there a query to add users in a batch?
  • 2009/12/10 12:55

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Make sure that you respect order :

Quote:

// Add real name
$name = $liste[0];
// End

// Add real name
$uname = $liste[1];
// End

// Add real name
$email = $liste[2];
// End

// Add Password
$pass= md5(trim($liste[5]));
// End

// Add website
$url = $liste[3];
// End

// Add website
$user_regdate = $liste[4];
// End

// Add avatar
$user_avatar = "blank.gif";
// End

$rank = "1";

$attachsig = "1";

$user_mailok = "1";


• First point : numbers wich appears between [ .. ] are column number in your .csv file
• Second point : you have to respect order in your sql query

Quote:
$query = "insert into ".$prefix."_users (
name,
uname,
url,
user_avatar,
user_regdate,
user_from,
user_sig,
pass, rank,
user_occ,
user_mailok,
email
)
VALUES ('".$name."','".$uname."', '".$email."','".$url."', '".$user_avatar."', '".$regdate."', '".$user_from."', '".$user_sig."', '".$pass."', '".$rank."', '".$user_occ."', '".$user_mailok."')";

13
planetexcel
Re: Is there a query to add users in a batch?

// Add real name 
$name $liste[0]; 
// End 

// Add real name 
$uname $liste[1]; 
// End 

// Add real name 
$email $liste[2]; 
// End 

// Add website 
$url $liste[3]; 
// End 

// Add website 
$user_regdate $liste[4]; 
// End

// Add Password 
$passmd5(trim($liste[5]));  
// End 

// Add avatar 
$user_avatar "blank.gif"
// End 

$rank "1"// Choose rank 

$attachsig "1";

$user_mailok "1"// Choose 1 if you allow administrator to send email 


// Add user in xoops_users table 
$query "insert into ".$prefix."_users (name, uname, email, url,user_regdate, pass, user_avatar, rank, attachsig, user_mailok) VALUES ('".$name."','".$uname."', '".$email."','".$url."', '".$user_regdate."', '".$pass."', '".$user_avatar."', '".$rank."', '".$attachsig."', '".$user_mailok."')"

$resultmysql_query($query); 
$uid mysql_insert_id(); 

//Add user in group : registered users per default 
$numgroup ='2';// choose Group number 
$query "insert into ".$prefix."_groups_users_link (groupid, uid) VALUES('".$numgroup."', '".$uid."')"
$resultmysql_query($query); 

if (
mysql_error()){ 
echo 
"Error in database : ".mysql_error(); 
echo 
"</table><br /><br /><b>Importation stoppee.</b><br /><br />"
fclose($fp); 
exit(); 
}else{ 
echo 
"<tr><td> ".$uid." </td><td> ".$uname." </td></tr> "



echo 
"</table><br />Import finished successfully.";// That's ok ! 

fclose($fp); 
?>


I believe this is the right order, but i still get a succesful upload without password, email, and name. Any help?? When i do an import the uid is keep updating. Can i reset it to 2? 1 is the admin user.

14
ghia
Re: Is there a query to add users in a batch?
  • 2009/12/11 9:32

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Are the other fields inserted in the database?
How does your csv looks like?

15
planetexcel
Re: Is there a query to add users in a batch?

I finaly inserted the file through phpadmin import feature. But all members inserted are inactive and without group. Is there an MySQL statement that could fix that?

16
Burning
Re: Is there a query to add users in a batch?
  • 2009/12/11 13:50

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Maybe an error here (blank space missing)
Quote:
url,user_regdate,


A line of your .csv file would be useful to help

Login

Who's Online

158 user(s) are online (97 user(s) are browsing Support Forums)


Members: 0


Guests: 158


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits