Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2010, 07:26 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chap 9 - problems using MySQL versions prior to version 5.

If you are using versions of MySQL prior to
version 5, you will have a problem. The problem is that
the rows "Unique Visitors" and "Top 10 IP Addresses"
will be empty.

The download code for report.php is using
aggregate functions in the ORDER BY clauses.
MySQL does not allow this in versions prior
to MySQL version 5.


You can workaround the problem by aliasing the aggregate in
the select statement.
Code:
Select  count(IP_ADDRESS) as theCount, ....
....
ORDER BY theCount ...
The result will be that you can use this for all versions of MySQL.

You will need to change this in 2 places.

1. Chapter 9, page 257, lines 2-18
2. Chapter 9, page 257, 4th line up from the
bottom, it has about 16 lines for the query statement.

THE DETAILS

The changed code for the first one is as follows. The
second one is similar. Note, my code is slightly different
in that I don't use DB_TBL_PREFIX.
Code:
$query = sprintf('
    SELECT
        COUNT(IP_ADDRESS) AS theCount,
        INET_NTOA(IP_ADDRESS) AS IP_ADDRESS
    FROM
        SITE_ACCESS SA
    WHERE
        DATE(ACCESS_TIME) BETWEEN
            "%d-%02d-01" AND
            "%d-%02d-01" + INTERVAL 1 MONTH - INTERVAL 1 DAY
    GROUP BY
        SA.IP_ADDRESS
    ORDER BY
        theCount DESC',
    $full_year,
    $num_month,
    $full_year,
    $num_month);
MY CONFIGURATION

I am using Wrox download code
MySQL server version 4.1.22
UNIX: FreeBSD 4.10





Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql version nightwhisper09 PHP How-To 0 October 4th, 2009 06:46 PM
Problems Converting Access mdb versions tailspin1 Access 1 April 16th, 2007 07:53 AM
Two versions of MySQL on localhost at same time TwoNames PHP Databases 2 April 21st, 2005 10:52 AM
How to update Mysql version qazi_nomi MySQL 1 September 8th, 2004 09:50 AM
How to update Mysql version qazi_nomi MySQL 1 June 14th, 2004 02:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.