I’m getting the following errors when I run the code below:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/adman4054/Public/auto_news/admin/statsCompanyURLredirects.php on line 39
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/adman4054/Public/auto_news/admin/statsCompanyURLredirects.php on line 46
Rows 39 and 46 are the 2 inner while loops with the first beginning
while($row = mysql_fetch_array($query2)) {
and the second beginning
while($row2 = mysql_fetch_array($query3)) {
I don’t understand why I am getting them because underneath the errors, the code displays all the correct data!
Can someone help me get rid of these errors and/or pinpoint what is causing them?
[CODE]
<?php
include(“../inc/conn.php”);
$query = mysql_query(“SELECT listingID, SUM(urlcount) from countslisting GROUP BY listingID ORDER BY SUM(urlcount) DESC”);
$num_rows=mysql_num_rows($query);
echo “<table width=’650′ align=’center’>”;
echo “<tr> <td width=’7′></td>”;
echo “<td width=’601′ align=’left’ valign=’top’ class=’bodyTxt’>”;
echo “<table>”;
echo “<tr><td class=’headerText’ align=’center’>Listing ID</td><td class=’headerText’>Company Name</td><td class=’headerText’ align=’center’>Total # of URL Redirects</td><td class=’headerText’ align=’center’>Today’s # of URL Redirects</td><tr>”;
//$exists = 0;
while($get = mysql_fetch_array($query)) {
$listingID = $get[‘listingID’];
//GET COMPANY NAME
$query2 = mysql_query(“SELECT listCompName FROM listing WHERE listingID = $listingID”);
[B]while($row = mysql_fetch_array($query2)) {[/B]
$companyName = $row[‘listCompName’];
}
//GET COUNT FOR TODAY
$today = date(“Y-m-d”);
$count=0;
$query3 = mysql_query(“SELECT SUM(urlcount) from countslisting WHERE listingID=$listingID AND listdate=’$today’ GROUP BY listingID”);
[B]while($row2 = mysql_fetch_array($query3)) {[/B]
$count= $row2[‘SUM(urlcount)’];
}
echo “<tr>”;
echo “<td class=’bodyTxt’ width=’150′ align=’center’ >”. $get[‘listingID’]. “</td>”;
echo “<td width=’350′ class=’bodyTxt’>”.$companyName.” </td>”;
echo “<td class=’bodyTxt’ width=’150′ align=’center’>”.number_format($get[‘SUM(urlcount)’],0).”</td>”;
echo “<td class=’bodyTxt’ width=’125′ align=’center’>”.$count.”</td>”;
echo “</tr>”;
}//end while
?>
</table>