mysql_fetch_array(): errors!?

mysql_fetch_array(): errors!?

am 08.10.2006 14:32:47 von Cerebral Believer

Hello,

I am having a few problems with this script, part of a package of scripts
designed to record website visitor data: I get the following errors:

---

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 41
Unique visitors: 0

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 53

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 58
Visited documents: 0

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 89
Top 50 Document PageviewsViews

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 126
CountTop 50 Referrers (excluding mesedilla.com pages and bookmark)

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 160
Total Top BrowsersCount

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in // webstats.php on line 195
Total Top ResolutionsCount

Query failed.Time StampDocument RequestedIP Address /
HostnameBrowserResolutionReferrer

---

Here is the script:

[CODE] //connect to the database
require("mojows_pro_def.php");

$mj_stamp = date("Y-m-d");

//connect to the database server
$mojows_connect = mysql_connect ($mojows_host, $mojows_username,
$mojows_password) or die ("Could not connect");

//select database
mysql_select_db ($mojows_database,$mojows_connect);
?>

align="center">




Mojo
Webstats Sample


bgcolor="99B3CC">



arial size = 1>
//process visitors
$mojows_query = "SELECT id FROM mojows_visitors ORDER BY id
DESC LIMIT 1";
$mojows_result = mysql_query($mojows_query);
$mojows_unvisitors = mysql_fetch_array($mojows_result);
$formatted_unique = number_format($mojows_unvisitors[id]);
print "  Unique visitors: $formatted_unique\n";

print "
\n";

//process documents
$mojows_query = "SELECT count FROM mojows_page";
$mojows_result = mysql_query($mojows_query);

$doc_count = "0";

while($row = mysql_fetch_array($mojows_result))
{
$doc_count = $doc_count + $row[count];
}

$mojows_documents = mysql_num_rows($mojows_result);
$doc_count1 = number_format($doc_count);
print "  Visited documents: $doc_count1\n";
?>


align="center">









src="shim.gif" width="1" height="10">
href="javascript:window.location.reload()">Refresh Mojo
Webstats
src="shim.gif" width="1" height="30">


bgcolor="99B3CC">




//process documents for today

$mojows_query = "SELECT page,title,count FROM mojows_page ORDER BY
count DESC LIMIT 50";
$mojows_result = mysql_query($mojows_query);

while($row = mysql_fetch_array($mojows_result))
{
$formatted_doc = number_format($row[count]);
print "\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\n";
}



?>
bgcolor="#003366">Top 50
Document Pageviews
face="arial" size="1" color="#FF9900">Views
bgcolor=#003366> href=$row[page]>$row[title] bgcolor=#003366>$formatted_doc
 


align="center">









src="shim.gif" width="1" height="10">
href="javascript:window.location.reload()">Refresh Mojo
Webstats
src="shim.gif" width="1" height="30">


bgcolor="99B3CC">




//process top referrers

$mojows_query = "SELECT referrer,count FROM mojows_ref WHERE
referrer NOT LIKE '%mesedilla.com%' && referrer!='bookmark' ORDER BY count
DESC LIMIT 50";
$mojows_result = mysql_query($mojows_query);

while($row = mysql_fetch_array($mojows_result))
{
$formatted_ref = number_format($row[count]);
print "\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\n";
}
?>
face="arial" size="1" color="#FF9900">Count bgcolor="#003366">Top 50
Referrers (excluding mesedilla.com pages and bookmark)
bgcolor=#003366>$formatted_ref
 
bgcolor=#003366> target=\"_blank\">$row[referrer]


align="center">









src="shim.gif" width="1" height="10">
href="javascript:window.location.reload()">Refresh Mojo
Webstats
src="shim.gif" width="1" height="30">


bgcolor="99B3CC">




//process total top browsers

$mojows_query = "SELECT b.name,c.version,count(c.version) AS
counter FROM mojows_stats AS a, mojows_bname AS b, mojows_bver AS c WHERE
a.bname=b.id && a.bver=c.id GROUP BY bver ORDER BY counter DESC";
$mojows_result = mysql_query($mojows_query);

while($row = mysql_fetch_array($mojows_result))
{
$formatted_count = number_format($row[counter]);
print "\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\n";
}
?>
colspan="2">Total Top
Browsers
face="arial" size="1" color="#FF9900">Count
bgcolor=#003366> 
$row[name]
bgcolor=#003366> 
$row[version]
bgcolor=#003366>$formatted_count
 


align="center">









src="shim.gif" width="1" height="10">
href="javascript:window.location.reload()">Refresh Mojo
Webstats
src="shim.gif" width="1" height="30">


bgcolor="99B3CC">




//process total top resolutions

$mojows_query = "SELECT resolution,count FROM mojows_res ORDER BY
count DESC";
$mojows_result = mysql_query($mojows_query);

while($row = mysql_fetch_array($mojows_result))
{
$formatted_res = number_format($row[count]);
print "\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\n";
}
?>
bgcolor="#003366">Total Top
Resolutions
face="arial" size="1" color="#FF9900">Count
bgcolor=#003366> 
$row[resolution]
bgcolor=#003366>$formatted_res
 


align="center">









src="shim.gif" width="1" height="10">
href="javascript:window.location.reload()">Refresh Mojo
Webstats
src="shim.gif" width="1" height="30">


bgcolor="99B3CC">









//process last 20 data
$mojows_query = "SELECT
a.stamp,b.page,b.title,c.ip,c.host,d.name,e.version,f.resolu tion,g.referrer
FROM mojows_stats AS a, mojows_page AS b, mojows_visitors AS c, mojows_bname
AS d, mojows_bver AS e, mojows_res AS f, mojows_ref AS g WHERE a.page=b.id
&& a.visitor=c.id && a.bname=d.id && a.bver=e.id && a.resolution=f.id &&
a.referrer=g.id ORDER BY a.stamp DESC LIMIT 50";

$mojows_result = mysql_query($mojows_query) or die ("Query
failed.");

while($row = mysql_fetch_array($mojows_result))
{
print "\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\t\n";
print "\t\n";
}

//close connection
mysql_close($mojows_connect) ;
?>[/CODE]

Can anyone help me work through this to resolve the errors, I have checked
on the MySQL site, but can't seem to get my head around why I am getting the
errors.

Regards,
CB.

Re: mysql_fetch_array(): errors!?

am 18.10.2006 04:33:34 von gooofy60

I don't know which version you have.
I downloaded v1.2
(http://sourceforge.net/project/showfiles.php?group_id=39638 &package_id=31804&release_id=122469)
and after installing the MySQL database, even with no entries, the
script ran without errors or warnings.

bgcolor="#003366">Time
Stamp
bgcolor="#003366">Document
Requested
bgcolor="#003366">IP Address /
Hostname
face="arial" size="1" color="#FF9900">Browser face="arial" size="1" color="#FF9900">Resolution bgcolor="#003366"> color="#FF9900">Referrer
bgcolor=#003366>$row[stamp] bgcolor=#003366>  href=$row[page]>$row[title] bgcolor=#003366>  $row[ip] /
$row[host]
bgcolor=#003366>  $row[name]
$row[version]
bgcolor=#003366> 
$row[resolution]
bgcolor=#003366>  target=\"_blank\">$row[referrer]