This has been driving me crazy all day. Out of hair to pull out so hoping for some help.
Trying to go through a database, selecting expired memberships, and setting those expired from active = ‘Y’ to active = ‘n’.
The script goes through the database fine, but when it encounters an expired member and updates active to ‘n’, it then goes into error trying to re-enter the cycle (continuing to scan database) and dies.
[php]
//Check all active members
$db = mysql_connect(“localhost”,“xxxx”,“xxxx”);
mysql_select_db(“paratb_members”,$db);
$result = mysql_query(“SELECT * FROM temporary WHERE active = ‘y’ AND exempt = ‘n’”,$db);
while ($row = mysql_fetch_array($result)) {
extract($row);
//some variables
$todaydate = $_SERVER[‘REQUEST_TIME’]; //current timestamp
$almostdue = strtotime("-3 months", $expiredate); //months to start warning
$whendue = date(‘F d, Y’,$expiredate);
if ($expiredate < $todaydate ){
//Change Member STATUS
mysql_select_db(“paratb_members”,$db);
$query = “update temporary SET active = ‘n’ WHERE id = ‘$id’”;
$result = mysql_query($query,$db) or die (“Error: (” . mysql_errno() . ") " . mysql_error());;
echo “User id: $id - DUES PAST DUE ON $whendue
”;
}
echo “Userid:$id - Members Status OK
”;
}
echo “DONE”;
[/php]
I get the following Error message (after changing database):
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/xxxx/public_html/tmp.php on line 7
line 7 is the original query:
[php] while ($row = mysql_fetch_array($result)) { [/php]
Any idea as to why it is going into fatal error after making the db change?
Any help would be greatly appreciated. Thanx
thanx