Testing and Making Your PHP Work
Website Automation with PHP and MySQL, Part 5
Low End Mac Reader Specials
Memory To Go Special: New 2008 iMac 2GB $42 / iMac Intel Core2 DUO & MacBook Pro 2GB $36 - 1GB $20. MacPro 8 Core Memory 8GB kit $286 / 4GB kit $143 / 2GB kit $93 -- Free shipping available. LIfetime warranty.
Download Typestyler, still the Ultimate Styling Tool for Internet, Print and Video Graphics. Works great in Classic with a Native OS X Version on the way. Free Tryout: www.typestyler.com
LA Computer Company: Specials on AppleCare, iMac's, Apple Batteries and Apple A/C Adapters. Also Great prices on Used Apple Computers. Call 1-800-941-7654 Click Here.
OWC: NewerTech miniStack FireWire/USB 2.0 HD & Hub Up to 1.0TB of Performance Storage + FW/USB2 Powered Hubs - convenient & sleek 6.5" x 6.5" x 1.5" Featured: 500GB $169.99; 750GB $209.99; 1.0TB $339.99
Mac users can finally play Party Poker for Mac. Not only that, they can also learn how to play PokerStars for Mac.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
Compare products like desktop computers, laptops, and LCD TVs side by side! All the information and reviews to make the best purchasing decision for a new cell phone GPS products or MP3 players. The Ciao network makes searching products easy for you.
Dan Knight - 2002.04.29
Last time we coded our PHP to work with our MySQL database and call up a different Mac of the Day each day.
Testing
After all that, it should have worked the first time - and it did.
Of course, that wasn't good enough. We'd created a full HTML page that worked, but we needed to be able to call this up from various pages on the site. test.html became test.txt, a file that would be called via Server Side Include - and then it didn't work any more.
Brian <http://brkn.net/> and I put our heads together, renamed the file test.php, called it that way, and it worked. On our server, you apparently have to make it part of the main HTML file or call it up in a file with the .php extension.
Then we tried to call the .php file from within a .txt file. We discovered that our server doesn't want to run .php files nested within include files. We'd have to modify the code on all the pages linking to the Mac of the Day to call in first a .txt file, then our new .php file, and then a closing .txt file.
That worked.
Adapting
The next step was to create a database for the email list of the day. The biggest difference here is that our list contains both Low End Mac email lists and a whole bunch run by The Macintosh Guy of Portland, so we'd need to use a full URL in the database. After creating the Mac of the Day, this was pretty trivial.
We also link to the Mac of the Day and the List of the Day in the navigation bar on the right side of almost every page on the site. Here we don't include the long text description, so we modified our code to look like this:
- <?php
- $host = "sqlserver.lowendmac.com";
- $username = "MyName";
- $password = "MyPassword";
- $connection = @mysql_connect($host,$username,$password);
- mysql_select_db(lem_mod,$connection);
- $today = round((date(U) + 32400) / 86400);
- $mod = $today % 89;
- $query = mysql_fetch_array(mysql_query("select * from mod where id = '$mod'"));
- echo "<B><BR>Mac of the Day</B><BR> <A HREF=/$query[link]>$query[model]</A>";
- $lod = $today % 38;
- $query = mysql_fetch_array(mysql_query("select * from lists where id = '$lod'"));
- echo "<B><BR>List of the Day</B><BR> <A HREF=\"$query[link]\">$query[listname]</A><BR>";
- ?>
Pretty trivial, but we ran into the same problem we'd had with the Mac of the Day bullet list - it had to be called in as a .php file. This became very time consuming, as we have thousands of pages on the site that used the menu.txt navigation file. In every single instance, we would have to replace that Server Side Include call with calls to a .txt file, a .php file, and another .txt file.
Using BBEdit Lite, that was also pretty trivial - but uploading thousands of changed pages probably took 3-4 hours. I hope we never have to go through that again.
It Just Works
So now pretty much every page on the site makes a couple of PHP calls to our MySQL database - once to display the Mac of the Day and then to display the Email List of the Day. Day in, day out the server automatically changes this sometime after midnight in Silicon Valley - even on weekends, even on holidays, even if I go on vacation.
And isn't that the whole point of computers, automating tedious tasks?
Next up: Houston, we have a problem.
Recent Online Tech Journal Columns
- Apple's AAUI ethernet connector, 09.04. From 1991 through 1995, Apple used a proprietary ethernet connection. Why they created AAUI and where to find adapters.
- PowerPC G5: Apple's last fling with PowerPC architecture, 05.24. Teaming up with IBM, Apple adopted the PowerPC G5 in 2003 - and phased out the last G5 Power Mac three years later.
- The PowerPC G4: From 350 MHz to 2.0 GHz, 05.24. AltiVec and dual processor support made the G4 a big improvement over the earlier G3 processor.
- The PowerPC G3 story: From 233 MHz to 1.1 GHz, 05.24. The history of the PowerPC 750 family and its use in Apple computers from 1997 through 2004.
- More in the Online Tech Journal index.
Links for the Day
- Mac of the Day: iMac G5 (iSight), Oct. 2005 -Apple built an iSight webcam into the last version of the G5 iMac.
- List of the Day: Leopard List Low End Mac's email list covering Mac OS X 10.5.
- October 12 in LEM history: 98: Beyond HFS+ nightmares - 99: iMacs for all - 00: The future of low-end gaming - 01: Tips on buying a new computer - 05: iMac G5 (iSight) - Simple backup strategies - 06: Bring back flexible, easy to upgrade 'Books - 07: Road Apple nominations - PB 150 boots from Compact Flash - Leopard to slow down PowerPC Macs?
Recent Content on Low End Mac
- TruePower Battery Can Run WallStreet PowerBook Past the 5 Hour Mark, Tommy Thomas, Welcome to Macintosh, 10.10. If you have a rugged old PowerBook but its battery is losing capacity, TruePower can give you plenty of time in the field.
- nVidia Inside Next MacBook?, Time for a Mac Netbook, Asus Launched MacBook Air Killer, and More, The 'Book Review, 10.10. Also photo reveals more about MacBook Pro, comparing 16:9 and 16:10 displays, Apple settles suit over faulty iBook and PowerBook adapters, bargain 'Books from $150 to $2,699, and more.
- 30% of iPhone 3G Buyers Switched Carriers, EU Battery Rule May Force iPhone Redesign, and More, iNews Review, 10.10. Also iPhone 3G greatest consumer electronics device ever, track presidential polls on your iPhone, Talking English Dictionary, waterproof armbands, several new iPhone apps, and more.
- Economic Crunch May Slow Mac Sales, a Recycled Cube, ToCA Race Driver 3 for Mac, and More, Mac News Review, 10.10. Also don't buy RAM from Apple, customize your Mac's appearance, MacTribe expanding into print, My Apple Space social networking, and more.
- Best Mac Pro Deals, Low End Mac Deals, 10.10. Used 2.66 GHz 4-core, $1,799; new, $1,949 after rebate; 2.8 4-core, $2,099 shipped; 8-core, $2,599 shipped; 3.0 $3,399 shipped; 3.2, $4,099 shipped.
- Best PowerBook G3 Deals, Low End Mac Deals, 10.10. Used 14" WallStreet G3/266 MHz, $90; Lombard G3/400 MHz, $150; Pismo G3/400 MHz, $300; 500 MHz, $350.
- Best Time Capsule and AirPort Deals, Low End Mac Deals, 10.10. Refurb 500 GB Time Capsule, $249; new, $294; refurb 1 TB, $419; new, $462; AirPort Extreme Card, $39; Base Station, $159; Express, $60.
- Modding Your Old Mac to Make It More Useful, Phil Herlihy, The Usefulness Equation, 10.09. If your old Mac is too slow, too noisy, too plain looking, or has too little room for expansion, you might want to mod it.
- What Would an $800 MacBook Mean for the Mac mini?, Dan Knight, Mac Musings, 10.09. If Apple does release an $800 entry-level MacBook next week, the $600 Mac mini is going to look very overpriced.
- Best iMac G4 Deals, Low End Mac Deals, 10.09. Used 15" 700 MHz CD-RW, $269; 800 Combo, $300; 1 GHz, $390; 17" 1.25 GHz SuperDrive, $400; 20", $529.
- Best 15" MacBook Pro Deals, Low End Mac Deals, 10.09. Used 1.83 GHz Core Duo, $995; 2.16, $1,125; new, 2.2, $1,400 after rebate; refurb 2.4, $1,699; 2.5, $1,999; 2.6, $2,299; rebates on new.
- Best Mac OS X 10.4 'Tiger' Deals, Low End Mac Deals, 10.09. DVD upgrade from 10.3, $75; upgrade bundle with 10.3, $118; full version, $129; family pack, $200; 10-user Server, $350; unlimited, $400.
- The Power of Older Macs, Why Vista Only Sees 3 GB of RAM, Wangwriter Supplies, and More, Charles W. Moore, Miscellaneous Ramblings, 10.08. Also the end of an era as MIT HyperArchive shuts down and another suggestion for profiling Windows computers.
- Migrating My Law Office from Windows to Macintosh, Andrew J Fishkin, Best Tools for the Job, 10.08. By switching to Leopard Server, everyone in the office will be able to move to a Mac - but which ones will best meet their needs?
- Low End Mac Needs Help Moving to Joomla, Dan Knight, Mac Musings, 10.08. We've settled on Joomla as the content management system that should work very well for Low End Mac, but we're running stuck with templates.
- Will Apple's iPhone/App Store Tornado Blow Away the Competition?, Tim Nash, Taking Back the Market, 10.08. The iPod, iTunes, and the iTunes Store paved the way for the success of the iPhone and the App Store - and nobody can match that.
- More links in our archive.
Go to the Online Tech Journal index.
About LEM | Support | Usage | Privacy | Contacts

