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 or Google+, or subscribe to our RSS news feed

Today's Links

Recent Content

About LEM Support Usage Privacy Contact

Follow Low End Mac on Twitter
Join Low End Mac on Facebook

Page not found | Low End Mac

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

Page not found | Low End Mac

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

Favorite Sites

MacSurfer
Cult of Mac
Shrine of Apple
MacInTouch
MyAppleMenu
InfoMac
The Mac Observer
Accelerate Your Mac
RetroMacCast
The Vintage Mac Museum
Deal Brothers
DealMac
Mac2Sell
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End Mac FAQ

Affiliates

Amazon.com
The iTunes Store
PC Connection Express
Macgo Blu-ray Player
Parallels Desktop for Mac
eBay

Low End Mac's Amazon.com store

Advertise

Well this is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.

Most Used Categories

Archives

Try looking in the monthly archives. :)

at BackBeat Media (646-546-5194). This number is for advertising only.

Open Link