I am getting
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result
resource in *filename* on line 81
While running a query to build a chart. The query gets data from the mysql db and uses it to build the chart.
Usually, I get this error and go to the code and find where I've screwed up, fix it, and move on. The tricky part about this problem is that the query is actually running and the chart is being built and displayed accurately. Why is my server (localhost on xampp) telling me that the query result is bad when it can utilize the resource just fine?
Here is the full query:
$chart=array();
$roll=array();
//select used terms
$rosh=mysql_query("select distinct term from search_terms");
while($roshrow=mysql_fetch_assoc($rosh)){
extract($roshrow);
$roll[]=$term;
}
//select term_number for each term
foreach($roll as $sterm){
$termarray=array();
**//following is line 81**
$bashq="select term_number from search_terms where term ='$sterm'";
$bash=mysql_query($bashq);
while($brow=mysql_fetch_assoc($bash)){
extract($brow);
//put results into array to sum
$termarray[]=$term_number;
}
$termsum=array_sum($termarray);
//put term=>number array for chart script
$chart[$sterm]=$termsum;
}
//sort array so high numbers at beginning
arsort($chart);
//slice top 10 terms
$chart=array_slice($chart,0,10);