Low End Mac Reader Specials
TypeStyler For Mac OS X is Now Shipping! Download The Free Fully Functional 60 Day Tryout at www.typestyler.com
Don't install Parallels to play poker online! Poker Mac will show you how
to download and install a native Mac poker application such as Full
Tilt Poker Mac.
Compare products like desktop computers, apple laptops, apple macs, and LCD Monitors side by side! All the information and reviews to make the best purchasing decision for new mobile phones, sat nav systems, or MP3 players. The Ciao online shopping community makes searching products easy for you.
Low End Mac's Online Tech Journal
More Link Automation and PHP Frustration
Website Automation with PHP and MySQL, Part 15
Dan Knight - 2002.07.31
Back in the Apple II+ era, my boss bought an Apple II+ system - and I discovered that I really enjoyed BASIC programming. AppleSoft BASIC was related to the Microsoft BASIC used by Commodore, CP/M machines, and most of the others.
The challenge was learning how BASIC worked by modifying programs, learning how the various dialects worked by converting them to AppleSoft BASIC (and later Commodore BASIC when I bought a VIC-20, GW-BASIC on my Zenith DOS machine, as well as Turbo BASIC and Quick BASIC).
Then I got a Mac, and I stopped programming - unless you count defining relationships between fields in Excel, FileMaker, and ClarisWorks programming. I never did get the hang of HyperCard and still don't understand AppleScript.
I don't pretend to understand PHP. I'm learning slowly, and I'm much less dependent on Brian and Steve for assistance, but when I need a fresh set of eyes to find a programming bug, one of them usually comes through.
I'm learning enough PHP to do what I want to do. And I've discovered that PHP isn't terribly well documented. A lot of the sample code I download from PHP.net doesn't work without some modification, and some of the information is simply wrong. That's frustrating.
Reading Email
My big programming project for the summer was going to be writing an email list management program that could handle dozens of lists while using a single subscription database. Anyone who runs a few busy lists probably knows the frustration of receiving "take me off your list" emails from subscribers who don't tell you which list.
That's one thing my program will address.
But instead of making progress, I've been stuck for almost a week trying to use the imap_open function. This is supposed to let me open a mailbox, then read and display the headers. Using the example on the PHP.net site (modified for my test address and password), I get error messages no matter what I do.
This is very frustrating, because I need to have this figured out before I can go anywhere with the project. And the imap_open function could also form the basis for creating a personal program to remove spam from my mailboxes.
More Low End Mac Automation
That may be frustrating, but this morning I began another aspect of automating things on Low End Mac.
When we publish new editorial content, we include a list of recent links at the end of the article. For some content, this is a generic "recent content" list, but for regular columns, we usually link to the 3 or 4 most recent articles in that series followed by other recent links on the site.
This morning I began automating that using pretty much the same techniques discussed in part 12. The big difference is a new section that displays the three most recent articles in that column (such as Mac Scope - our sample) and then recent links excluding those from that column.
I'm not going to post all the code, but here are the relevant parts:
- $get_links = mysql_query("SELECT * FROM links WHERE timestamp <= $rightnow and columnname = 'Mac Scope' ORDER BY timestamp DESC LIMIT 3");
- while ($array = mysql_fetch_array($get_links))
- {
- echo "<li><a href=\"$array[path]$array[html]\">$array[linktext]</a>, ";
- $shortdate = $array[pubdate];
- $shortdate = substr ($shortdate, -5);
- $shortdate = strtr ($shortdate, '-', '.');
- echo "$shortdate.
- $array[description]</li>";
- }
- echo "<li>More in the <a href=/musings/index.shtml>Mac Scope index</a>.</li>";
The first line finds the three most recent Mac Scope columns and sorts them in descending order by date. The subroutine displays the column title, link, date, and description. Since Mac Scope is always written by Stephen Van Esch, there's no need to display the author's name or the column title (Mac Scope) here.
The rest of the code is almost unchanged from what we came up with in part 12. The only real difference is excluding Mac Scope columns:
$get_links = mysql_query("SELECT * FROM links WHERE pubdate = '$latestdate[pubdate]' and timestamp <= $rightnow and columnname != 'Mac Scope' ORDER BY rank DESC");
The != is PHP's way of saying "not equal," which some languages write as <> and your math teacher probably taught you as an equal sign with a slash through it.
Once I had the script working properly, all I had to do was change the calls that had been made to a manually updated include file and instead call my PHP script. It works beautifully.
What Next?
For now, I'm pretty happy with how things are working. It'll take some time to get all of the sections updated with these new scripts, but there's no big hurry - nor is it a tedious job.
I'd eventually like to work on a submission system where writers could turn in articles online, maybe even writing some PHP to analyze content and take a stab at picking the best words to use in META tags. But there's no hurry.
The next big project will be Email List Automation Using PHP and
MySQL. Assuming I can solve the imap_open problem.
Recent Online Tech Journal Columns
- Optimized Software Builds Bring Out the Best in Your Mac, 06.30. Applications compiled for your Mac's CPU can load more quickly and run faster than ones compiled for universal use.
- Low End Mac's Safe Sleep FAQ, 06.15. What is Safe Sleep mode? Which Macs support it? How can you enable or disable it? And more.
- The Original Macintosh, 01.12. An in-depth look at the original Macintosh and how it shaped future Macs.
- The Innovative Lisa, 01.08. Apple's Lisa and how it paved the way for the Macintosh.
- More in the Online Tech Journal index.
Links for the Day
- Mac of the Day: iMac Core2, Sep. 2006 - Apple introduced the biggest screen ever in an iMac with a 24" Core2 Duo model at 2.16 GHz.
- Group of the Day: G-List is for Power Mac G3, G4, and G5 users.
- March 21 in LEM history: 00: The compelling Mac - 01: All that for $129? - PowerBook 100 - 02: Improving AppleWorks - 03: The G3 ain't dead yet - Pismo a good value - Western Digital drive issues - 05: iPod halo effect - 06: Rip DVDs so you can watch them on your iPod - 07: Maximum drive size in older Macs - 08: Safari 3.1 fastest browser?
- Support Low End Mac
Recent Content on Low End Mac
- Does iPhone OS Need Multitasking?, iCab Comes to iPhone, Canada's Proposed iPod Levy, and More, iNews Review, 03.19. Also the iPad paradox, Freescale demos $200 tablet, gardening apps, aluminum iPhone stand, steel iPhone case, and more.
- Could iPad Replace the Mac?, Mac Sales Up in 2010, Avoiding Windows 7 'Whenever Possible', and More, Mac News Review, 03.19. Also why your next Mac may be an iPad, science blogger abandons Apple, the benefits of standing while working, and more.
- The Mobile System Stampede, Lithium Battery That Can't Explode, Affordable SSD Options, and More, The 'Book Review, 03.19. Also June 2007 MacBook Pro external display issue, laptop stands, 1 TB ultraportable hard drive, Mini DisplayPort/HDMI adapter, and more.
- How to Zoom Your Browser for a More Readable Web, Steve Watkins, The Practical Mac, 03.18. Instructions for zooming text and pages in Safari, Firefox, Camino, and Opera.
- CardBus WiFi, the Shiira Browser, Ridding the Web of Flash, and Macs vs. PCs, Charles W. Moore, Miscellaneous Ramblings, 03.18. Mac longevity, Shiira speed, ambidextrous Mac and Windows use, and how Flash benefits Apple.
- How Ad Blocking Hurts Your Favorite Websites, Charles W. Moore, Miscellaneous Ramblings, 03.18. Ad income keeps the Web free. Blocking online ads hurts your favorite websites.
- Taking Apart the 12" PowerBook, John Hatchett, Recycled Computing, 03.17. There are a lot of steps involved in disassembling a 12" PowerBook. Proceed with caution.
- More links in our archive.
Recent Deals
- Best Intel iMac Deals, 03.17. Used 17" from $600; 20" from $750; 24" from $825; refurb 21.5" nVidia, $999; new, $1,099; refurb Radeon, $1,299; new, $1,399; refurb 27" 3.06, $1,499; more.
- Best G5 iMac Deals, 03.17. 17" 2.0 GHz, $380; 1.9 GHz iSight, $479 shipped; 20" 1.8 GHz, $509 shipped; 2.1 GHz iSight, $549 shipped.
- Best Time Capsule Deals, 03.17. Close-out 500 GB, $140; new 1 TB, $279; used 2 TB simultaneous dual-band, $400; new, $455. Shipping included.
- Best iPad Deals, 03.16. 16 GB iPad, $499; 32 GB, $599; 64 GB, $699; 16 GB with 3G, $629; 32 GB 3G, $729; 64 GB 3G, $829. Free ground shipping.
- Best iPod classic Deals, 03.12. Used 20 GB, $119; 40 GB, $139; 60 GB, $159; 30 GB video, $129; 60 GB, $159; 80 GB, $169; refurb 120 GB, $189; new, $214; 160 GB, $228 shipped.
- Best G3 iBook and AirPort Card Deals, 03.12. 366 MHz 12" clamshell, $89; 466, $125; 500 white CD, $100; 600, $199; 800 Combo, $239; 14" 900, $225.
- Best Xserve Deals, 03.12. Used 1 GHz dual G4, $499; 2.0 dual G5, $599; 2.3, $749; refurb 2.26 4-core Nehalem, $2,499; new, $2,699; 8-core, $3,449; refurb 2.66, $4,299; new, $4,799; more.
- More deals in our archive.
About LEM | Support | Usage | Privacy | Contacts
Navigation
Used Mac Dealers
Apple History
Video Cards
Email Lists
Favorite Sites
MacSurfer
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
Museum
DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System
6 Heaven
System 7 Today
the pickle's Low-End
Mac FAQ
Abandonware
Petition
Mac vs. PC Info
Affiliates
The Apple
Store
Mac
Connection
B&H
MacMall
TechRestore
ExperCom
Crucial
Memory
batteries.com
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
Museum
DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End
Mac FAQ
Abandonware
Petition
Mac vs. PC Info
Mac Connection
B&H
MacMall
TechRestore
ExperCom
Crucial Memory
batteries.com
