I am getting the following error, not sure what I need to do to fix this... [quote]Warning: mysql_fetch_array(): 6 is not a valid MySQL result resource in /usr/local/apache2/htdocs/homepbx/kevin/home/cdr.php on line 23[/quote] [code] <?php $connection=mysql_connect("host","db","pass"); if (!$connection) { echo "Could not connect to MySql server!"; exit; } $db=mysql_select_db("asterisk",$connection); if (!$db) { echo "Could not select database"; exit; } $sql = 'SELECT * FROM `table`'; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); if ($num_rows == 0) { echo "Sorry, we have no records"; } else { echo "<div align=\"center\"><table summary=\"HomePBX Call Detail Records\" cellspacing=\"0\" cellpadding=\"0\"><caption>$name's Call Detail Records</caption>"; echo "<tr><th class=\"title\">Call Date</th><th>Caller ID</th><th>Source</th><th>Destination</th><th>Duration</th></tr>"; while ($row=mysql_fetch_array($mysql_result)) { $result=$mysql_result; $id=$row["calldate"]; $var_1=$row["clid"]; $var_2=$row["src"]; $var_3=$row["dst"]; $var_4=$row["duration"]; $i = 0; while (($row=mysql_fetch_row($result)) !== false) { $i++; echo "<tr class=\"d".($i & 1)."\">"; echo "<td>".$row[0]."</td>"; echo "<td>".$row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td>".$row[3]."</td>"; echo "<td>".$row[4]."</td>"; echo "</tr>\n"; } mysql_free_result($result); } } mysql_close($connection); ?> </table></div> [/code] is this because of double while statements??? if I try to remove the [quote]while ($row=mysql_fetch_array($mysql_result)) {[/quote] I no longer get my data... all I am trying to accomplish with this right now is that the rows alternate color.. this is working, except for the error.... Any help will be greatly appreciated. Kind Regards, Smarthouseguy