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.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
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
Importing Data into Your MySQL Database
Website Automation with PHP and MySQL, Part 3
Dan Knight - 2002.04.25
Last time we created our database with four fields: id, link, model, and text. Now we need to fill the database.
Again, there are two ways to do things. The hard way is to use Telnet and manually enter all of your data. The easy way, assuming you have the data in a file, is to import your information.
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. Three fields time nearly 100 Macs would take a long time.
Besides, I already had everything in HTML format. Here's the line for the Mac Plus as an example:
- <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.
I wanted to break this down to three fields: link, model, and text, as follows:
- link: compact/plus.shtml
- model: Mac Plus
- text: (1/86-10/90). First Mac with SCSI, memory expansion. Longest model life - over 4 years.
I'd add the id field manually, since it didn't exist in my HTML file.
The first step was to take the raw HTML from my file and copy it into TextSoap, a powerful program for cleaning up text with manual line breaks, extra spaces, and other problems. Running the scrub command reconnected the HTML lines that Home Page had nicely broken into pieces.
Then we copied that code to BBEdit Lite, where our next step was to eliminate the extra space between lines of code. Search for \r\r (two returns) and replace with \r. Then save the file to the desktop.
As Brian < http://brkn.net/> explained to me, before you go any further you need to "escape" things like quote marks. So we did a global search for the quote mark and replaced it with \" - the backslash is used to indicate that the next character is literal instead of punctuation. We did the same with parentheses.
Our Mac Plus description now looked like this:
- <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 also stripped out the unnecessary HTML code such as <A HREF="/ and "> and </A> . Because MySQL likes to work with comma delimited files, we replaced "> with ", " and also replaced </A> with ", ". Now it looked like this:
- compact/plus.shtml", "Mac Plus", "\(1/86-10/90\). First Mac with SCSI, memory expansion. Longest model life - over 4 years.
That had us most of the way there, but we still needed to add quote marks at the start and end of each line, so we had BBEdit search for \r and replace it with "\r". Three fields down; one to go.
- "compact/plus.shtml", "Mac Plus", "\(1/86-10/90\). First Mac with SCSI, memory expansion. Longest model life - over 4 years."
Next we manually numbered every line in our database. The Mac Plus is the 27th in our list, so the entry now looked like this:
- "27", "compact/plus.shtml", "Mac Plus", "\(1/86-10/90\). First Mac with SCSI, memory expansion. Longest model life - over 4 years."
Brian and I had created 89 records that were just about ready to be imported into the MySQL database we'd created. Just a couple more steps. We needed to preface each line with INSERT INTO mod (id,link,model,text) VALUES( and append ); to the end of the line. Again, we did a search for the return (\r in BBEdit) and replaced it with );\rINSERT INTO mod (id,link,model,text) VALUES( - resulting in the following
- INSERT INTO mod (id,link,model,text) VALUES("27", "compact/plus.shtml", "Mac Plus", "\(1/86-10/90\). First Mac with SCSI, memory expansion. Longest model life - over 4 years.");
It probably takes longer to explain the steps than it took to do them. Then it was time to import the whole text file into MySQL using PHPMyAdmin. It failed the first two or three times because I'd accidentally given two lines the same number.
Once the import was successful, we were done. The database had been
created. Now all we needed to do was use the data to create Mac of the
Day entries.
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: 17" MacBook Pro Core Duo, Apr. 2006 - The top-end MacBook Pro includes a 1680 x 1050, 2.16 GHz Core Duo CPU, and supports Apple 30" Cinema Display.
- Group of the Day: G4 List is for those using Power Mac G4s or G4 upgrades.
- Support Low End Mac
Recent Content on Low End Mac
- Pismo WiFi Networking Issue Finally Solved?, Charles W. Moore, Miscellaneous Ramblings, 11.24. It turns out the problems wasn't the Pismo, the Buffalo WiFi card, or Mac OS X 10.4. It was the Wireless G router - Linksys to the rescue!
- Mini VGA to S-video Adapter a No Go for eMacs, Dan Bashur, Apple, Tech, and Gaming, 11.24. You might think that Apple's Mini VGA S-video adapter is a cheap way to connect your eMac or G4 iMac to your TV. You would be wrong.
- Google Calendar with iPhone or iTouch Is Great for Scheduling, John Hatchett, Recycled Computing, 11.24. Web-based Google Calendar allows access and updates from any computing platform, including Mac, Windows, Linux, and iPhone OS.
- Why Spaces is My Favorite Leopard (and Snow Leopard) Feature, Charles W. Moore, Miscellaneous Ramblings, 11.23. Spaces, a feature introduced with OS X 10.5, is like having several monitors on your Mac without the cost and space of using multiple displays.
- i5 iMac Benchmarked, Mac mini 'Shouldn't Be Overlooked', Twitter Client for Classic Mac OS, and More, Mac News Review, 11.20. Also why Apple leaves the low end to others, 10.6.2 fixes video playback problem in 27" iMac, 3D Leopard and Snow Leopard performance, and more.
- Apple's Tablet an End Run Beyond Netbooks, Frank Fox, Stop the Noiz, 11.20. Whatever Apple has planned will leverage existing technologies while going beyond what its competitors can offer.
- Apple #4 in Reliability, Apple Tablet a Gadget for All?, HP's i7 Notebook Outdoes Mac Rivals, and More, The 'Book Review, 11.20. Also Flash 10.1 improves video on Hackintosh netbooks, thin-and-light notebooks impress, Windows XP finally on the way out, and more.
- NASA Chemical Sensor for iPhone, Smartphone Death Match, iPhone Earrings, and More, Ian R Campbell, 11.20. Also mobile phone dangers, new apps, GPS solution for iPod touch, new iPod and iPhone cases, and more.
- More links in our archive.
Recent Deals
- Best iPod nano Deals, 11.25. Refurb 8 GB 4G nano, $99; new, $126; refurb 16 GB, $129; new, $150; new 5G/8 GB, $134.60; 16 GB, $161.12. Shipping included.
- Best Classic Mac OS Deals, 11.25. System 6.0.8 floppies, $10; 7.1, $12; 7.5, $20; 7.6 $13; 8.1, $11; 8.5, $20; 8.6, $90; 9.0, $20; 9.2.2, $30.
- Best 15" PowerBook G4 Deals, 11.25. Used 1 GHz Combo, $400; 1.5 GHz SuperDrive, $449; 1.67 GHz hi-res, $600.
- Best G4 iMac Deals, 11.24. Used 15" 700 MHz CD-RW, $150; 800 MHz Combo, $229; 1 GHz, $289; 17" 1.25 GHz, $200; 20" 1.25 GHz, $509.
- Best MacBook Air Deals, 11.24. Used from $899; refurb from $1,099; new 1.6 GHz/120 HD, $1,150 after rebate; 1.8/64 SSD, $1,150 a/r; 1.86/128 SSD, $1,350 a/r; 2.13/128 SSD, $1,694 a/r.
- Best PowerBook G3 Deals, 11.24. Used 233 MHz WallStreet, $75; 266 MHz, $160; 400 MHz Lombard, $199; 400 MHz Pismo, $289; 500 MHz, $350.
- Best 12" PowerBook G4 Deals, 11.23. Used 867 MHz SuperDrive, $348; 1 GHz Combo, $379; SD, $519; 1.33 GHz, $529; 1.5 GHz Combo, $549; SuperDrive, $609.
- Best Mac Pro Deals, 11.23. Used 2.66 GHz 4-core, $1,300; 3.0 4-core. $1,919; refurb 2.66 4-core Nehalem, $2,149; 2.93, $2,549; 2.93 8-core, $4,999; new 2.26 8-core, $2,290.
- Best Time Capsule and AirPort Deals, 11.23. Used 802.11g AirPort Extreme, $49; 500 GB Time Capsule, $150; new, $190; 1 TB dual-band, $280; 2 TB, $469; 802.11n AirPort Extreme, $170.
- 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
Advertise
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
