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.
Join us on Facebook. Follow us on Twitter.
Recent Online Tech Journal Columns
- Optimized Software Builds Bring Out the Best in Your Mac, 2009.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, 2009.06.15. What is Safe Sleep mode? Which Macs support it? How can you enable or disable it? And more.
- The Original Macintosh, 2009.01.12. An in-depth look at the original Macintosh and how it shaped future Macs.
- More in the Online Tech Journal index.
Links for the Day
- Mac of the Day: Mac IIfx, introduced 1990.03.19. This 'wicked fast' 40 MHz Mac trumped the 33 MHz DOS world.
- February 14 in LEM history: 98: A perfect compact Mac - 00: Extended computer warranties worth the cost? - Making your PC work with your Mac - 01: Customize Microsoft Word - 02: Quadra revives a passion for computing - 03: Real world performance - DIY Pismo screen replacement - Best Mac for writing - 03: Fastest browser on the Mac - 06: 15" MacBook Pro - Impressions of a newly acquired Lisa - Finding and using free WiFi - Apple should liberate OS 9 - 07: New Mac mini cheaper than upgrading a Power Mac - 08: Falling in love with OS X
- Support Low End Mac
Recent Content on Low End Mac
- PowerBook 165c: 19 Years of Color to Go, Chris Carson, Building Bridges, 2012.02.14. Until 1993, all of Apple's notebook computers had black and white displays. The 165c gave us a color PowerBook for the first time.
- Mac and iOS Browsers: Options Galore, Freeware Forum, 2012.02.10. Safari is adequate on Mac and great on iOS, but the range of good alternatives is stunning. LEM writers share their favorites.
- White MacBook Goes End-of-Life, Logitech Touch Mouse Supports Gestures, Firmware Updates, and More, The 'Book Review, 2012.02.10. Also MacBook Air better than any Ultrabook, docks for MacBook Pro models, Intel offers improved SSDs, and more.
- Fix Home Button Delay, Tablet the Ultimate Mobile PC, iPad Notebook a Possibility, and More, iOS News Review, 2012.02.10. Also using your iPad at work, two photo editors, a new iPad text editor, Macally's magnetic iPad 2 stand, and more.
- Apple's Support Lead Shipping, Smartphones Outsell PCs, OS X Ported to ARM by Intern, and More, Mac News Review, 2012.02.10. Also the power of Tex-Edit Plus, Google and Twitter are already censoring the Web, Snow Leopard Security Update, and more.
- LogMeIn: Remote Screen Sharing for the Rest of Us, Alan Zisman, Zis Mac, 2012.02.09. Configuring the Mac's built-in screen sharing to work over the Internet can be difficult or impossible. LogMeIn makes it easy.
- More links in our archive.
Recent Deals
- Best 17" MacBook Pro Deals
- Best iPod classic Deals
- Best eMac Deals
- Best MacBook Air Deals
- Best iBook G4 Deals
- Best iPad Deals
- Best Classic Mac OS Deals
- Best Apple TV Deals
- More deals in our archive.
About LEM Support Usage Privacy Contact
Follow
Low End Mac on Twitter
Join Low End Mac
on Facebook
Low End Mac Reader Specials
TypeStyler 11 is now in the Mac App Store!! -- Special Introductory Price of $59.95!! -- To Buy From The Mac App Store Click Here Now!! Or buy direct
from Strider Software.
Don't install Parallels to play poker online! Poker Mac will show you how to download and install a native Mac poker and Mac Casino applications in minutes.
Favorite Sites
MacSurfer
Cult of Mac
Shrine of Apple
MacInTouch
MyAppleMenu
InfoMac
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac Museum
DealMac
Deal Brothers
Mac2Sell
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End Mac FAQ
Affiliates
Amazon.com
The Apple Store
The iTunes Store
PC Connection Express
GainSaver
Parallels Desktop for Mac
eBay

