My csv file has 5600 records The php script only updates about 500 records and
stops. How can I get it to update all records.
//the script
<?php $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
set_time_limit(0);
ignore_user_abort(True);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo "Webstar MYSQL Update Utility 1.0"; ?></title>
<link href="mycss.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#0000FF" alink="#009933">
<div align="center">
<table width="355" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCFFFF">
<!--DWLayoutTable-->
<tr align="left">
<td width="355" height="33" valign="middle" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="54" align="center" valign="top" bgcolor="#FFFFFF"><p><form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<input border="0" src="update.gif" name="submit" width="145" height="33" type="image" />
<input name="MM_update" type="hidden" value="form1">
</form></p>
</td>
</tr>
<tr>
<td height="53" align="left" valign="top" bgcolor="#FFFFFF" class="mainfont">
<?php
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
$link = mysql_connect("localhost", "username", "password") or die("Could not connect: ".mysql_error());
$db = mysql_select_db("databasename") or die(mysql_error());
// yourfile.csv must be in the same directory as this php file
$handle = fopen ("imports/test.CSV","r");
while ($data = fgetcsv ($handle, 1000, ",")) {
$atsign = "@no.mail";
$username = $data[0];
$user_password = $data[1];
$email = $data[0].$atsign;
$isactive = $data[2];
if($isactive == "4"){$isactive = "0";}
else {$isactive = "1";}
$ulevel = $data[2];
if($ulevel == "4"){$ulevel = "0";}
else {$ulevel = $data[2];}
$us_password = md5($data[1]);
$query = "UPDATE phpbb_users SET `user_active` = '$isactive', `username` = '$data[0]', `user_password` = '$us_password', `user_session_time` = 0, `user_session_page` = 0, `user_lastvisit` = 0, `user_regdate` = 1120962206, `user_level` = '$ulevel', `user_posts` = 0, `user_timezone` = 0.00, `user_style` = NULL, `user_lang` = '', `user_dateformat` = '', `user_new_privmsg` = 0, `user_unread_privmsg` = 0, `user_last_privmsg` = 0, `user_emailtime` = NULL, `user_viewemail` = 0, `user_attachsig` = 0, `user_allowhtml` = 1, `user_allowbbcode` = 1, `user_allowsmile` = 1, `user_allowavatar` = 1, `user_allow_pm` = 0, `user_allow_viewonline` = 1, `user_notify` = 0, `user_notify_pm` = 1, `user_popup_pm` = 0, `user_rank` = NULL, `user_avatar` = '', `user_avatar_type` = 0, `user_email` = '$email', `user_icq` = '', `user_website` = '', `user_from` = '', `user_sig` = '', `user_sig_bbcode_uid` = NULL, `user_aim` = '', `user_yim` = '', `user_msnm` = '', `user_occ` = '', `user_interests` = '', `user_actkey` = '',
`user_newpasswd` = '' WHERE `username` = '$data[0]'";
$result = mysql_query($query) or die("Invalid query: <BR>" . mysql_error().__LINE__ ."<BR>"."Source code ". __FILE__);
$query2a = "UPDATE `phpbb_user_group` SET `user_pending` = 0 WHERE `usergid` = '$data[0]'";
$result2a = mysql_query($query2a) or die("Invalid query: <BR>" . mysql_error().__LINE__ ."<BR>"."Source code ". __FILE__);
$query3a = "UPDATE `phpbb_groups` SET `group_type` = 1, `group_name` = '$data[0]', `group_description` = 'Personal User', `group_moderator` = 0, `group_single_user` = 1 WHERE `usergsid` = '$data[0]'";
$result3a = mysql_query($query3a) or die("Invalid query: <BR>" . mysql_error().__LINE__ ."<BR>"."Source code ". __FILE__);
$query4a = "UPDATE `phpbb_auth_access` SET `auth_view` = 0, `auth_read` = 0, `auth_post` = 0, `auth_reply` = 0, `auth_edit` = 0, `auth_delete` = 0, `auth_sticky` = 0, `auth_announce` = 0, `auth_vote` = 0, `auth_pollcreate` = 0, `auth_attachments` = 0, `auth_mod` = '$ulevel', `userauthid` = '$data[0]' WHERE `userauthid` = '$data[0]'";
$result4a = mysql_query($query4a) or die("Invalid query: <BR>" . mysql_error().__LINE__ ."<BR>"."Source code ". __FILE__);
}
echo "User List Updated";
//mysql_close($link);
fclose ($handle);
}
?>
</td>
</tr>
</table>
</div>
</body>
</html>