Creating Your My SQL Database
Website Automation with PHP and MySQL, Part 2
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 4GB kit $154 / 2GB kit $94 -- Free shipping available.
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.
MacBook/MacBook Pro / MacMini / iMac Intel Core2 DUO DDR2 667Mhz 4GB Kit $80, 3GB Kit $60, 2GB Kit $40, 1GB $20 - Click to Maximize your Macs...
Dan Knight - 2002.04.24
What is PHP? I can't summarize it any better than Try a New Language: PHP:
- PHP is an open-source, server-side, cross-platform scripting language that is used to generate dynamic Web pages or to build browser-based applications. The PHP script can be embedded in the HTML page to generate HTML code that is inserted in the Web page at that point, or the PHP script can generate the entire HTML output. One of PHP's strengths is easy database integration.
That database integration usually comes from a MySQL database, another open-source standard. For our purposes, creating a database will be the first thing we do - before we even begin programming in PHP. (And it's all free.)
Creating the Mac of the Day Database
The first piece of Low End Mac we be automated was the Mac of the Day. I have a list of nearly 100 Apple models and clones, along with a page link and a brief note on the model's significance. Here's what the Mac Plus entry looks like in HTML:
- <A HREF="/compact/macintosh-plus.html">Mac Plus</A> (1/86-10/90). First Mac with SCSI, memory expansion. Longest model life - over 4 years.
We could create a database containing that entire text string or create one with separate fields for the link, the model name, and the description. Neither system is inherently better than the other, but using three fields will create a system where editing the description could be done with no risk of messing up the link or the model name. It will also have a second benefit, which I'll mention later.
MySQL has three types of string or text records. (Other record types are numeric and time-related.) The CHAR type uses fixed length strings, while VARCHAR allows variable string lengths. Although that's a more efficient use of space, VARCHAR adds overhead and reduces performance. Both of these field types are limited to 255 characters, which will be plenty for our needs.
The third string record is BLOB or TEXT fields, which can be as large as 65,535 characters. We might use such fields when we work with mailing lists and articles, but we don't need such large fields right now.
The longest model name is under 30 characters, and the longest link is just over 20 characters, so we'll give ourselves a bit of room and give the model name field a maximum length of 32 and the link a maximum size of 24 characters.
A few of the descriptions are around 100 characters, so we'll set the maximum size for that text field to 128 characters.
To create the database, you'll need to log into the MySQL server you'll be using. Your ISP or system administrator should be able to provide all the information you need to do that. If you're using Telnet, type the following at the prompt to create your database:
mysql> create database macs;
This creates an empty database named "macs" - and it's just waiting for us to create a table for our data. We'll be creating the following fields:
mysql> CREATE TABLE mod ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> link CHAR(24), -> model CHAR(32), -> text CHAR(128), -> );
The first line creates a table called "mod" (Mac of the Day") within our database. The first field gives each record a unique and automatically created ID number with a maximum value way up there in the billions. PRIMARY KEY declares id as the primary field in this table, meaning it is the one MySQL will index and access most readily.
- NOTE: I didn't do it this way. My son Brian <http://brkn.net/> told me about a program called PHPMyAdmin that's much easier than using Telnet.
All that remains is to move the data from my current HTML file into MySQL.
Filling the Mac of the Day Database
Call me lazy, but I simply don't want to spend a lot of time rekeying this information or doing the cut-and-paste thing.
.
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 Core2, Sep. 2006 - Apple introduced the biggest screen ever in an iMac with a 24" Core2 Duo model at 2.16 GHz.
- List of the Day: Old Mac MP covers 604-based multiprocessor Macs and clones.
- September 6 in LEM history: 99: G4 vs. Pentium III - 00: Setting up a server - 02: Norton Utilities warning - 10 greatest computer annoyances - 06: iMac Core2 Duo - Mac mini Core Duo - The iMac Core2 value equation - 07: Apple seduction - Why I really want an iPod touch - iPod history, 2005 to present - Upgrading a Power Mac G - Apple intros iPod touch, classic, and video nano
Recent Content on Low End Mac
- Anticipation: New iPods Now, New Macs Later, Kev Kitchens, Kitchens Sync, 09.05. The season of new iPods is at hand, but new Macs may wait until 2009.
- Buy a MacBook Now or Wait?, MacBook touch Patents, Samsung X360 Takes on MBA, and More, The 'Book Review, 09.05. Also 20 years of portable Macs, data backup and preservation, universal U-Charge battery charger for Mac 'Books, bargain 'Books from $150 to $2,699, and more.
- Listen to Just the Music with the V-Moda Vibe Earbuds, Tommy Thomas, Welcome to Macintosh, 09.05. Well built, the noise canceling earbuds will let you hear all the nuances of your music without letting through background noise.
- Source of iPhone 3G Problems, Army Uses iPods as Field Translators, Gains with Business, and More, iNews Review, 09.05. Also UK bans iPhone ad as 'misleading', iPhone password easy to bypass, GM to offer radios with USB in 2009 models, weather tracking software, and more.
- Macs Gain Ground in August, Consumers Most Likely to Buy Macs, LaCie USB Speakers, and More, Mac News Review, 09.05. Also migrating Time Machine to a new drive and two new keyboards from Logitech.
- Best iPod touch Deals, Low End Mac Deals, 09.05. Refurb 8 GB, $199; new, $284; refurb 16 GB, $299; new, $370; refurb 32 GB, $399; new, $453.
- Best 15" MacBook Pro Deals, Low End Mac Deals, 09.05. Used 1.83 GHz Core Duo, $999; 2.16, $1,125; new, 2.2, $1,450 after rebate; refurb 2.4, $1,699; 2.5, $1,999; 2.6 Santa Rosa, $1,849; rebates on new.
- Best iMac G4 Deals, Low End Mac Deals, 09.05. Used 15" 700 MHz CD-RW, $279; 800 Combo, $300; 1 GHz $390; 17" 800 MHz SD, $439; 1.25 GHz, $449; 20", $569.
- Overclocking a Mac mini Got Me Hooked on Souping Up Macs, Adam Geller, My First Mac, 09.04. Stories of hot rodding iBooks, G3 iMacs, and PCI Power Macs on the cheap.
- Apple Will Not Abandon Optical Drives, the Mac Drought, Purposeful Mac Acquisition, and More, Dan Knight, Low End Mac Mailbag, 09.04. Also Mac OS X 10.5 on a G4-upgraded Blue & White G3 and problems using a flat panel display with a Quadra 700.
- Only Leopard Runs Routine Maintenance Tasks after Startup or Waking from Sleep, Charles W. Moore, Miscellaneous Ramblings, 09.04. Mac OS X 10.5 runs routine system maintenance scripts as soon as possible after starting up or waking up your Mac. Earlier versions of OS X do not do this.
- Tomorrow's Solid State Drives and Notebooks, Dan Knight, Mac Musings, 09.04. Flash drives are great but have some shortcomings. Some thoughts on building better SSDs and notebooks to use them.
- Best 12" PowerBook G4 Deals, Low End Mac Deals, 09.04. Used 867 MHz Combo, no APX, $490; 1 GHz, $550; SuperDrive, $625; 1.5 GHz w/o APX, $660; w/APX, $675.
- Best Mac mini Deals, Low End Mac Deals, 09.04. Used 1.25 GHz G4 SD, $549; 1.42 Combo, $409; new 1.83 Core2 Combo, $569 after rebate; 2.0 SD, $769 after rebate.
- Best 17" PowerBook G4 Deals, Low End Mac Deals, 09.04. Used 1 GHz, $779; 1.33 GHz, $799; 1.5 GHz, $859; 1.67 GHz, $910.
- 11 Mac Browsers Compared, Simon Royal, Mac Spectrum, 09.03. The latest versions of Internet Explorer, Opera, Safari, Shiira, iCab, Radon, Firefox, Netscape Navigator, SeaMonkey, Flock, and Camino tested in Leopard.
- Save Internet Radio, USB and Hard Drives, Hardware Manufacturers vs. Linux, and More, Dan Knight, Low End Mac Mailbag, 09.03. Also Mac won't book after cleaning, newer versions of OS X improve wake from sleep, downgrading to OS 8.6, unreadable pages on Low End Mac, and more.
- Another Free POP3 Provider, Recharging a Dead PRAM Battery, Current Kanga Value, and More, Charles W. Moore, Miscellaneous Ramblings, 09.03. GMX email now available in US, Panasonic UJ-841S drive won't burn discs, restoring a dead PRAM battery in a Pismo, and thoughts on Kanga value today.
- Best eMac Deals, Low End Mac Deals, 09.03. Used 700 MHz Combo, $120; 1.25 GHz SuperDrive, $150; 1.42 GHz, $349.
- Best Mac OS X 10.5 'Leopard' Deals, Low End Mac Deals, 09.03. Mac OS X 10.5, single user, $99; 5 users, $140; 10.5 Server, 10 users, $395; unlimited, $850.
- Best MacBook Air Deals, Low End Mac Deals, 09.03. Refurb 1.6 HD, $1,499; new, $1,690 after rebate; refurb 1.8, $1,699; new, $1,919 a/r; refurb 1.6 SSD, $2,099; new, $2,294 a/r; refurb 1.8, $2,299; new, $2,400 a/r.
- Psystar Strikes Back, Countersues Apple, Frank Fox, Stop the Noiz, 09.03. Psystar is trying to paint Apple as a monopoly and force it to license the Mac OS.
- More links in our archive.
Go to the Online Tech Journal index.
About LEM | Support | Usage | Privacy | Contacts

