PHP undefined variables in while loop

hey guys. Im getting this error…

Notice: Undefined variable: user_sites in c:\Inetpub\wwwroot\adcore\earn_top.php on line 17

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in c:\Inetpub\wwwroot\adcore\earn_top.php on line 17

Notice: Undefined variable: user_sites in c:\Inetpub\wwwroot\adcore\earn_top.php on line 18

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in c:\Inetpub\wwwroot\adcore\earn_top.php on line **18

**and this is my code…

11	 $users_sites = mysql_query("select id,credits from sites where site_owner=".$_SESSION["uid"]." AND status=0;",$conn);
12 	$reccount_user_sites = mysql_num_rows($users_sites);
13 	if($reccount_user_sites >0) {
14 	$divide_credits = $increment/$reccount_user_sites;
15 	$reccount_get = 0;
16	 while($reccount_user_sites > $reccount_get) {
17	     $while_credits = mysql_result($user_sites,$reccount_get,"credits");
18	     $while_id = mysql_result($user_sites,$reccount_get,"id");
19	     $while_new_credits = $while_credits + $divide_credits;
20		mysql_query("UPDATE sites SET credits=".($while_new_credits/10)." WHERE id =".$while_id.";",$conn);
21	     $reccount_get++;
22	     }
23	 }else{

I’m new to php, so dont be too mean :slight_smile:

thanks for the help
-Naaman