Can you try this function ()in pnadmin.php (simply replace the old one):
function pnCPG_admin_SyncPN() {
// first get configuration parameter
$selconfig = pnModGetVar('pnCPG', '_inifile');
// if not supplied, insert default value
if(!$selconfig){
$selconfig="config.ini";
}
$configfile =getcwd() ;
$configfile.="/modules/pnCPG/pnconfig/";
$configfile.=$selconfig ;
$ini_array = parse_ini_file($configfile);
$CPGloc1=$ini_array[cpg_location];
$cpg_loc=trim($CPGloc1);
$_cpg_prf = $ini_array[cpg_prefix];
$db=$ini_array[cpg_database];
$_dbhost=$ini_array[cpg_pn_host];
$_dbuser=$ini_array[cpg_pn_dbuser];
$_dbpw=$ini_array[cpg_pn_dbpwd];
$_pnroot=$ini_array[cpg_pn_root];
$makealbum=$ini_array[cpg_create_album];
$_pn_prf = pnConfigGetVar('prefix');
// Load Postnuke users
$results = mysql_query( "SELECT pn_uname,pn_email FROM $_pn_prf LIMIT 0 , 999999" );
//store the result in a PHP array for multiple use
$dbdata=array();
$dbdata1=array();
$usr_num = 0;
while($row = mysql_fetch_array($results)) {
$usr_num ++;
$dbdata[$usr_num]=$row[0];
$dbdata1[$usr_num]=$row[1];
}
// is there another database owner, let's connect
if ($_dbhost !==""){
$link = mysql_connect($_dbhost, $_dbuser, $_dbpw) or mysql_error();
}
$true = mysql_select_db($db) ;
$teller = 0;
while ($teller < $usr_num ){
$teller ++ ;
$username = $dbdata[$teller];
$usermail = $dbdata1[$teller];
// Check if already added to Coppermine
$results1 = mysql_query( "SELECT * FROM $_cpg_prf WHERE user_name=$username " );
$num_rows1 = mysql_num_rows($results1);
// if not there, add the account
if ($num_rows1 < 1){
$cpg_pwd = ranpass() ;
$adding = mysql_query("INSERT INTO $_cpg_prf(user_group, user_active,user_name, user_password,user_lastvisit, user_regdate,user_email) VALUES ('2','YES', '$username','$cpg_pwd',NOW(), NOW(),'$usermail')");
if ($makealbum == 'y'){
$results = mysql_query( "SELECT * FROM $_cpg_prf where user_name='$username' " );
$USER_DATA = mysql_fetch_array($results);
$temp_user_cat = $USER_DATA['user_id'];
$temp_user_cat = $temp_user_cat + 10000;
mysql_query("INSERT INTO $_cpg_album(title, description, visibility, uploads, comments, votes, pos, category, pic_count, thumb, last_addition, stat_uptodate, keyword) VALUES ('$f_username', '', '0', 'NO', 'YES', 'YES', '1', '$temp_user_cat', '0', '0', '0', 'NO', '$f_username')");
}
} else {
//update e-mail
$updating = mysql_query("UPDATE $_cpg_prf set user_email = '$usermail' where user_name='$username' limit 1");
}
}
$true = pnDBInit();
// Return
return true;
}