|
Posted by Cerebral Believer on 10/08/06 12:32
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]<?php
//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);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="left" valign="top"><font color="#FF9900" size="4">Mojo
Webstats Sample</font></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width=100% align=left valign=top bgcolor=#003366><font face =
arial size = 1>
<?php
//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 "<br>\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";
?>
</font></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="10"></td>
</tr>
<tr>
<td align="left" valign="top"><font color="#FF9900" size="2"><a
href="javascript:window.location.reload()">Refresh Mojo
Webstats</a></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="30"></td>
</tr>
</table>
<table width="440" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width="400" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">Top 50
Document Pageviews</font></td>
<td width="40" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Views</font></td>
</tr>
<?php
//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<tr>\n";
print "\t\t<td width=400 align=left valign=top
bgcolor=#003366><font face = arial size = 1><a
href=$row[page]>$row[title]</a></font></td>\n";
print "\t\t<td width=40 align=right valign=top
bgcolor=#003366><font face = arial size = 1>$formatted_doc
</font></td>\n";
print "\t</tr>\n";
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="10"></td>
</tr>
<tr>
<td align="left" valign="top"><font color="#FF9900" size="2"><a
href="javascript:window.location.reload()">Refresh Mojo
Webstats</a></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="30"></td>
</tr>
</table>
<table width="640" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width="40" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Count</font></td>
<td width="600" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">Top 50
Referrers (excluding mesedilla.com pages and bookmark)</font></td>
</tr>
<?php
//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<tr>\n";
print "\t\t<td width=40 align=right valign=top
bgcolor=#003366><font face = arial size = 1>$formatted_ref
</font></td>\n";
print "\t\t<td width=600 align=left valign=top
bgcolor=#003366><font face = arial size = 1><a href=\"$row[referrer]\"
target=\"_blank\">$row[referrer]</a></font></td>\n";
print "\t</tr>\n";
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="10"></td>
</tr>
<tr>
<td align="left" valign="top"><font color="#FF9900" size="2"><a
href="javascript:window.location.reload()">Refresh Mojo
Webstats</a></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="30"></td>
</tr>
</table>
<table width="300" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width="250" align="center" valign="top" bgcolor="#003366"
colspan="2"><font face="arial" size="1" color="#FF9900">Total Top
Browsers</font></td>
<td width="50" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Count</font></td>
</tr>
<?php
//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<tr>\n";
print "\t\t<td width=200 align=left valign=top
bgcolor=#003366><font face = arial size = 1>
$row[name]</font></td>\n";
print "\t\t<td width=50 align=left valign=top
bgcolor=#003366><font face = arial size = 1>
$row[version]</font></td>\n";
print "\t\t<td width=50 align=right valign=top
bgcolor=#003366><font face = arial size = 1>$formatted_count
</font></td>\n";
print "\t</tr>\n";
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="10"></td>
</tr>
<tr>
<td align="left" valign="top"><font color="#FF9900" size="2"><a
href="javascript:window.location.reload()">Refresh Mojo
Webstats</a></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="30"></td>
</tr>
</table>
<table width="180" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width="130" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">Total Top
Resolutions</font></td>
<td width="50" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Count</font></td>
</tr>
<?php
//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<tr>\n";
print "\t\t<td width=130 align=left valign=top
bgcolor=#003366><font face = arial size = 1>
$row[resolution]</a></font></td>\n";
print "\t\t<td width=50 align=right valign=top
bgcolor=#003366><font face = arial size = 1>$formatted_res
</font></td>\n";
print "\t</tr>\n";
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="10"></td>
</tr>
<tr>
<td align="left" valign="top"><font color="#FF9900" size="2"><a
href="javascript:window.location.reload()">Refresh Mojo
Webstats</a></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#003366"><img
src="shim.gif" width="1" height="30"></td>
</tr>
</table>
<table width="1550" border="0" cellspacing="1" cellpadding="0"
bgcolor="99B3CC">
<tr>
<td width="110" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">Time
Stamp</font></td>
<td width="300" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">Document
Requested</font></td>
<td width="300" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1" color="#FF9900">IP Address /
Hostname</font></td>
<td width="70" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Browser</font></td>
<td width="70" align="center" valign="top" bgcolor="#003366"><font
face="arial" size="1" color="#FF9900">Resolution</font></td>
<td width="700" align="center" valign="top"
bgcolor="#003366"><font face="arial" size="1"
color="#FF9900">Referrer</font></td>
</tr>
<?php
//process last 20 data
$mojows_query = "SELECT
a.stamp,b.page,b.title,c.ip,c.host,d.name,e.version,f.resolution,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<tr>\n";
print "\t\t<td width=110 align=center valign=top
bgcolor=#003366><font face = arial size = 1>$row[stamp]</font></td>\n";
print "\t\t<td width=300 align=left valign=top
bgcolor=#003366><font face = arial size = 1> <a
href=$row[page]>$row[title]</a></font></td>\n";
print "\t\t<td width=300 align=left valign=top
bgcolor=#003366><font face = arial size = 1> $row[ip] /
$row[host]</font></td>\n";
print "\t\t<td width=70 align=left valign=top
bgcolor=#003366><font face = arial size = 1> $row[name]
$row[version]</font></td>\n";
print "\t\t<td width=70 align=left valign=top
bgcolor=#003366><font face = arial size = 1>
$row[resolution]</font></td>\n";
print "\t\t<td width=700 align=left valign=top
bgcolor=#003366><font face = arial size = 1> <a href=\"$row[referrer]\"
target=\"_blank\">$row[referrer]</font></td>\n";
print "\t</tr>\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.
Navigation:
[Reply to this message]
|