Hello
I tried to add a "top search" on my pages like on header.php but I keep getting this type of error:
Warning
: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
...\includes\database.php
** I followed all steps from the thread 892, created the table and queries are logged ok, i have no table prefix in config.php, and I can't get it to work.
I tried to create a file "top_search.php" with :
<?php
print "<p>Top Searches</p>";
print "<ul>";
$sql = "SELECT * FROM querylog ORDER BY count DESC LIMIT 10";
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
$url = $config_baseHREF."search.php?q=".urlencode($row["query"]);
print "<li><a href='".$url."'>".$row["query"]."</a></li>";
}
}
print "</ul>";
?>
on header.php (or other pages) I call the file with an include:
<?php
include('top_search.php');
?>
Any idea what could be wrong?
Thanks
Pat
Hello Pat,
I think the problem may be that count is a reserved word and so will have to be enclosed in back-ticks within the SQL. Try this:
$sql = "SELECT * FROM querylog ORDER BY `count` DESC LIMIT 10";
Cheers,
David.