Importing Large Files into MySQL using phpMyAdmin and CPanel

When I need to upload large .sql file (greater than 10 MB) into MySQL using phpMyAdmin, it frequently times out.

The annoying the solution is to split the SQL file into several smaller file, but text editors will hang up if the file is too large, and if you aren’t careful you can break the whole script.

That is why I like David Pratt’s solution. It worked great.

1. If you have phpMyAdmin installed in CPanel, you need to login to your server using your root password. Navigation to the folder:

/usr/local/cpanel/base/3rdparty/phpMyAdmin

2. There, create a directory “upload”.

3. Next, look for config.php and change the line:

$cfg['UploadDir'] = '';

to

$cfg['UploadDir'] = 'upload';

4. Save the file, and upload your .sql script into that upload directory.

5. Now when you go to the import tab in your phpMyAdmin, you will have a new option under “File to Import”, called “Or web server upload directory”.

6. Select the file you uploaded from the drop down menu.

Switching to the Mac: Buying a Mac

Almost 10 months ago, I purchased my first Mac. Because a lot more of my website work was less Microsoft and more Open Source, it made more sense. I also wanted to learn iPhone / iPad development which is impossible without a Mac.

For an employed Windows developer, it was scary, confusing and exhilarating. There were so many questions swimming in my head:

Was I going to be able to perform my normal job?
Would it take long to learn OS X?
Would I have to purchase a lot of software?
Would I like it?
Am I throwing my money away?

By far, the biggest problem was the money. Everyone knows that Mac’s are expensive, and I wasn’t willing to spend $3,000 on a device I may land out hating.

Step 1: Programs, Files, Mail

The first step was to figure out how I would move my files, mail and programs to the Mac, if i was able to find one. This is what I found:

  1. All my regular files could be backed up and easily transferred.  The Mac can read standard Windows NTFS drives, and read and write to old FAT32 drives.
  2. I migrated all my email to a Google Apps account, so all my email was in the cloud and didn’t have to be transferred directly. This was a HUGE time saver.  I followed Scott Hanselman’s advice on how to move my email without losing mail.
  3. I called Adobe and made sure I could transfer my Photoshop license to the Mac.
  4. Lastly, I went through every program I use, and found replacements for the Mac.

Step 2: Finding the Right Mac

As a developer, I need a more beefy machine than the average computer user. I had grown accustomed to a 17″ laptop, but because this was an experiment, I wasn’t going to spend money on that. I had to have a laptop, so that eliminated the iMac’s and the lower end Macbook.

So, I definitely needed a Macbook Pro, but couldn’t afford to purchase one new.

I went to craisgslist.org and started using this query to find what I needed:

http://losangeles.craigslist.org/search/sss?query=macbook+pro+-13.3+-13+-wanted+-air+-hp+-jbl+-trade+-white&catAbbreviation=sss&minAsk=600&maxAsk=1400

In short, it is looking in Los Angeles for a Macbook Pro, but asking it to not return any listings that mention “13.3”, “13”, “wanted”, “air”, “hp”, “jbl”, “trade” and “white”. I also specified to only see listings between $600 and $1400.  This narrowed the results down enough for me to look through every day. I added it to my Google Reader so that I would receive notifications the instant one appeared.

In under a week, I found a listing for a late 2008 model, just prior to the current Unibody model, with software and Applecare warranty for $1,000.  I called and offered to come over immediately with $900 cash and he agreed. He was suprised I was willing to do this at 8 pm at night, but I knew if this mac wasn’t “too good to be true”, I would lose it by the next day.

Step 3:  Buying A Used Mac

I didn’t know how to figure out if I was buying a good machine or not.  I didn’t even know how to login to a Mac, or how to look at the processor.  Luckily the seller’s roommate was able to answer my questions.

The main place to look was in “About This Mac” which you access by clicking the Apple logo located in the upper left of the screen.  This showed me the processor and memory, and then when I clicked “More Info…”, I found the Battery Cycle Count which told me how many times it had been charged.  This number was ridiculously low, confirming the story that he never used the laptop.

He also said he had purchased a 3 year warranty from Apple, but I couldn’t confirm that there.  I had his address, so I decided to buy it and go to the Apple store the next day, which did confirm the warranty.

Lastly, the Mac came with a hard cover ($60 – $80), a bag, and software discs of Microsoft Office and Final Cut Pro.  I found that many used Mac ads claim that it comes with lots of commercial software, but they rarely come with the discs – usually meaning that they are pirated.  Having the original discs with license keys proved to me they were original.

I sold Final Cut Pro on eBay for about $150, which I used to upgrade the RAM from 2 gigs to 4, and allowed me to purchase some additional software.

With everything out the door, I got a 1 year old Macbook Pro with 2.5 Ghz Core 2 Duo with 4 Gigs of RAM, Microsoft Office, Bag, Case and a 2 year Applecare Warranty for about $800.

It IS possible to buy a solid Macbook Pro for under $1,000 – I did it. You just have to have your wits about you and be aware of anything that smells shady. In my case, I got the seller talking and learned that he received the Macbook for the Film School he paid a lot of tuition to attend. He soon learned he didn’t want to be a Film Maker, and therefore never used the Mac.

In the next part of Switching to the Mac, I will discuss learning OS X and the software I decided to buy.

Integrating Forums with WordPress

There are three viable options if you want to leverage WordPress as your Content Management System, yet want to offer your users a way to interact in a forum.

  • bbPress
  • phpbb
  • vBulletin

bbPress

bbPress logo
bbPress is a very lean forum solution for WordPress written by Automatic.  It is a great idea for a quick and dirty forum that works.  Theming works similarly to WordPress – so if you enjoy writing themes in WordPress, this will be easy.

I had to install it in a subdirectory. Trying to install it in the same directory as WordPress causes a battle over index.php since they both need it.

For the most part, you just need to install it, and follow the directions. Here are my tips:

  1. Make sure bb-config.php is writeable.  I didn’t find that out I needed to until I got an error message.
  2. When it is asking you for the “salt” strings, you can go here to view it if needed: /wp-admin/options.php
  3. I didnt read this until after my first attempt, but by following this you should be fine:
    http://www.wpmods.com/integrate-wordpress-bbpress

Mods:

Latest Discussion For WordPress – This will allow you to see the forum posts in your wordpress sidebar

Notes:

If you can’t get to the bbPress Admin Site after integration, just delete the following keys in your bbPress database that refer to the WordPress database.

bb-press-database-fix

After spending several hours trying to figure out how I broke the bbPress Admin Site, I gave up and just installed bbPress into the WordPress database.

phpBB

phpBB logo
phpBB is a much more robust (bloated) forum.  And the integration is done with one major plugin, WP-United.

You must follow directions exactly.  There are about 30 files you need to edit, and if you zone out and start watching ESPN, it isn’t going to end happy for you.

There are over 20 code changes you need to make in the phpBB files, and the instructions sometimes say “replace”, “add before” and “add after”.  It is easy to overlook these and add your code after a line instead of before.

Once it is installed, you can use various Template Tags in your WordPress theme to show forum posts and statistics.

Theming is also really nice – there are files you can edit just like bbPress.  You just need to learn some of the phpBB conventions they use in the HTML.

Notes

  • I couldn’t get the logged in user to show logged in under comments.
  • Basic features like adding users by an administrator requires an additional plugin.
  • If you have to upgrade phpBB in the future, you will have to make all those edits all over again.

vBulletin

vBulletin logo
vBulletin is extremely robust, but so much so that it is really hard to figure out where to configure various settings.  But because of the large user community, a simple google or vBulletin forum search will tell you where to look.

vBulletin is not free like phpBB or bbPress, but you do get what you pay for.  You get free Technical Support, and for a little more money you can even get free telephone support.

You can view an online demo on their site before you purchase, and if you buy it and change your mind, you can get your money back within 30 days.

The major benefit with vBulletin is that it opens the door for you to start charging for paid membership.  vBulletin integrates with many payment providers and can charge one time or recurring.

Mods

vBulletin-Wordpress Bridge:  This will map vBulletin user groups to WordPress user groups and allow single sign on.  Just make sure you follow the instructions and go to fast.  (Do the test post before you go and turn it on all the way.)

Simple vB Login – This gives us our login form on the WordPress side.

If you want to access the vBulletin user, you need to put “global $vbulletin;” in the login_inc.php and possibly the header.php of your theme.

Hidepost (custom) – The normal Hidepost plugin allows you to hide content from various user groups.  I changed hidepost to look at $vbulletin user instead of wordpress user (although you may not always have to do that).

Notes:

  • Logging into vBulletin is confusing.  You can login at vbulletin.com, but all your user information is on members.vbulletin.com.  And then you have to add an email address to your account to access vbulletin.org where the user community and mods are located.

Summary

  • If you think a forum would be nice, but you don’t know if it will be successful or not, go with bbPress.
  • If you want a full featured forum, no matter how complex, go with vBulletin.
  • If you think you would EVER want to have a paid membership with hidden content, you must use vBulletin.
  • If you like the idea that you can email or call someone for help, use vBulletin.
  • If you like the features of vBulletin, but you REALLY don’t want to spend the money, then go with phpBB.

How To Properly Setup and Configure Godaddy DNS Settings

If you buy domains through Godaddy, but host the website and mail somewhere else, chances are you had to edit your DNS settings.

Up until a few weeks ago I had been doing it wrong.  It was working, for the most part, but some things like reverse dns lookups would fail, and strange errors would sometimes crop up.

When you buy your domain through Godaddy, find your way into Total DNS Control.  You will see a page similar to this:

Scary, that’s for sure.

Now, before we can edit this, you need to know where your website is going to be hosted.  So if you are hosting at Hostgator.com for example, you would sign up with them and they would give you the IP Address to use for your site.

Armed with that IP Address, you can start editing your DNS Record.  Keep in mind that this is not gospel – your mileage may vary.  This works for me everytime when I point to a website I am setting up in CPanel and also need to manage the mail.  If you want your mail through Godaddy, then you do not want to make these changes.

  1. Switch to advanced mode so that you can edit more than one line at a time.
  2. Change the @ A(Host) @ record to your new IP.
  3. Delete every CNAME except for www and ftp
  4. Add the mail A(Host) Record for mail pointing to the same new ip.
  5. Delete the MX record with Priority 0.
  6. Change the priority 10 record to mail.YOU-DOMAIN-NAME.COM
  7. Add new SPF record and follow the following prompts
    1. Choose “an ISP or other mail provider”
    2. inbound tab: all inbound servers may send mail
    3. outbound tab: all addresses in A records
    4. PTR tab: include PTR
    5. The resultant line should look like “v=spf1 a mx ptr ~all”

Your DNS should now look like this:

Nasty IIS/ASP Querystring Cookie Case Bug

I just stumbled on a nasty, nasty ASP bug that took about 7 years for me to see.

The problem happens when using cookies and querystrings with the same name. A page on the site reads in a variable from the querystring and sets a cookie with the same name to its value, e.g.:

strSrc = Request.QueryString(“A”)
Response.Cookies(“A”) = strSource
Response.Cookies(“A”).Expires = Now + (2 * 30)

However, if the variable name in the query string is different from the capitalization of the cookie name (e.g page.asp?a=xxx) then a new cookie gets set with the name matching the captialization of the
QueryString variable.

So if you run the page multiple ways, a=123 and A=123, two different cookies are set EVEN THOUGH YOUR CODE SAYS Response.Cookies(“A”) = strSource!

Attempting to read the cookie value back then returns both values. Reading the cookie value via Request.ServerVariables(“HTTP_COOKIE”) shows both values.

If your code is looking for the “A” cookie later on and there are two cookes there, you will only see the “A” one, which may not be the one you want.

Since I ran into this, I did see other complain about this as far back as 2003: here, here, here.

0.0.0.0 Gateway Causing No Internet Access

Sometime last week, I stopped being able to get access to the internet while at work.  I could get an IP address from DHCP, but couldn’t get any traffic past our firewall/gateway.

I thought it was DHCP server, and was ready to buy a new one as it is 5 years old.  But then I noticed in my ipconfig /all that I had two gateways:  0.0.0.0, and then on the second line, my correct gateway, 192.168.1.1.  I had never seen two gateways listed, and almost scanned right over it.

I confirmed that no matter if I set the IP manually, or dynamically, I couldn’t get rid of the 0.0.0.0 gateway.

I called my friend, the who knows all the technical nitty gritty in the TCP world.

We fired a command prompt and I printed my computer’s current route table by writing “route print”:

Route Print Before

You can clearly see the two lines showing 0.0.0.0.  According to him, there should only be one line.  So we deleted them both:

Route Delete

This left us at:

Route Print Middle

So then we added the correct one back in:

Route Add

I did one more “route print” to make sure it took:

Route Print After

And viola, I have internet access!

Myspace Statistics

I am watching a programming presentation from the Myspace tech team right now. They are going over their stats and was blown away by the numbers (as of April 2007):

Myspace

  • 185 Million Registered Users
  • 50.2% Female / 49.8% Male
  • Primary Age Demo: 14 – 34
  • Over the last 5 months, had between 39 and 45 Billion page views per month.
  • The second biggest site was Yahoo around 35 Billion. MSN, Google, Ebay and Facebook are all way behind with under 15 Billion.
  • 350,000 new registrations each day
  • 1 Billion total images on the site, 80 Terabytes of space, 150,000 requests per second
  • Millions of new images/day
  • 25 Million Songs, 142 Terabytes of space, 250,000 concurrent streams
  • With Videos, 60 Terabytes of storage, 15,000 concurrent streams, 60,000 new videos / day
  • 4.5 Million people on site on any one time
  • 7 Datacenters
  • 6000 web servers
  • 650 ad servers
  • 250 database servers
  • 70,000 megabits per second bandwith (I run over 20 sites, some considered “large” and I don’t go above 2 mb/s
  • 80% ASP.NET, 20% Coldfusion

Delete Files Older Than Date Using Batch Files

This problem has nagged at me for years.  Here is a batch command to delete files on a Windows 2003 machine.

Forfiles -pC:\backup -s -m*.* -d-5 -c "cmd /c del /q @path"

This will delete all files in my backup directory older than 5 days. To test it first, use this:

Forfiles -pC:\backup -s -m*.* -d-5 -c "cmd /C Echo 0x22@Path\@File0x22"

This will print out each file that you will be deleting.

Now playing: Lamb Of GodTerror And Hubris In The House Of Frank Pollard