Of all the plugins I've set up so far, this one gave me the most trouble. I visited the ip2nation thread on planetOzh, downloaded the plugin, tinkered with it for a while and failed. Then I revisited the ip2nation thread and read everything again. Looked at all the examples... all the Q&A. Tried tinkering again and failed... again.
I gave up. But not for long. I just needed to take a break. I worked on other things. After my break from this plugin (it was about two days), I was back at it. I started reading things more carefully. The first time I had uploaded the ip2nation.sql file to my web server. Naturally that didn't work. So I read where it was recommended that I download PHPMyAdmin. Another learning curve for me, but okay. I downloaded it, put it on my server and tried to run it. As most everything else I've uploaded for the sake of this blog, it would not work straight off the download server. It kept muttering some errors. Something about how it couldn't connect or login, or some such other nonsense. Stupid fucking computers.
Turns out all the data in this blog is stored in a sql database which was created when I installed WordPress. Did I mention I am new at this? I gotta say the installation was a snap. modhost (my web host), has WordPress, among many other items that are available for very simple installs at the cpanel screen. I did a coupla clicks and bam! I was off and running. It was nearly idiot proof. I fired it up and I've been poking away at it ever since. So evidently this PHPMyAdmin thing is some sort of database editor and it was whining that it did not know the username and password to access the WordPress sql database. Imagine that. And I thought computers were smart. So where was "I" going to find out this username and password?
So I am not a brain surgeon or a rocket scientist, but I can be resourceful. I started poking around in the WordPress files on my server. I found one file called wp-config.php. It was here that I found the the info I needed. It was even in English, not Geekish. The comment tags said in very plain English, "The name of the database", "Your MySQL username", "...and password". Bingo. Looks like I found it. But where do I put it? It never ends...
I went back to my PHPMyAdmin directory on my server. I started poking around those files. There was a similar one called config.inc.php. This is where I needed to put my username and password. I also changed the phpMyAdmin url and I think I pretty much left every other parameter at the default value (and there were a boatload of parameters). I uploaded my updated config.inc.php file, refreshed my PHPMyAdmin screen and viola'! Back in business.
Note: I installed Gallery the same way (from the cpanel screen). After the install, my webhost emailed me a confirmation of the Gallery installation. This email referenced yet another MySQL database, username (no MySQL password for this one though). Unfortunately, I received no such email regarding my WordPress install. What's my point? If you install stuff like this from your cpanel screen, check your email. If they send you the info automatically, it may save you some time.
Another Note: I should not have to say this, but if you are putting your hands all over these files, changing them, and re-uploading them, make sure you rename the original on your web server before you upload your edited config file. That way you can always revert back to the default values and start over. (Not that I've ever fucked up an important config file). ahem...
Okay so I'm going down the mental check list in my head and checking things off as I go. Got the ip2nation sql database file. Check. Got the PHPMyAdmin thing uploaded, configured, and running. Check. Getting closer now. I seemed to recall somewhere about creating a coupla databases. One called ip2nation the other called ip2nationCountries. I tried to create a new database and I got an error that said I didn't have the proper permissions for that. This was a crushing blow for me. I thought, "all this progress for nothing". I thought well maybe I can find some other way to massage this ip2nation.sql file into what I need. I trashed PHPMyAdmin. It did not work for me, so why should it stay on my server taking up space? I figured I'd do more research, but thought it would be wise to revisit the ip2nation thread to see if I missed anything.
So I read where somebody had the same problem as I did with creating the databases. The Wizard of Ozh himself spoke and said that we were not supposed to create a database, but rather create "tables" in the existing database. Duh. I knew that. Okay not really. This was a ray of hope for me. Perhaps I really DID have all the permissions I needed to make this work. but...
I trashed my PHPMyAdmin. shit.
I still had it on my local computer. I just reuploaded, reconfigured, re-ran and I was back in like Flynn. Woohoo! Okay so tables... tables... tables... I'm looking... clicking... looking... clicking some more... looking... wtf? How the hell do I create these tables? It's back to the ip2nation thread I go. There are a LOOOOOOT of posts there, so it's very possible I just missed that part. Of course. Yeah. That's it. I just missed that part.
So I go back and again in the wise words of the great Wizard of Ozh, it turns out I was supposed to Click on the SQL Tab along the top of the screen. Ohhhhh. I got it. So I click and I see a button where I am to choose a file... as in the ip2nation.sql file which has been hanging out on my desktop. I pressed the button, browsed for the file, selected it, followed the onscreen instructions and waited. And waited. And waited. It wasn't really that long of a wait, but... it seemed like it to me. PHPMyAdmin was doing its thing with the database I fed it, and when it was finished, I noticed two new tables in the list of tables to the left of the screen. Fuckin' awesome! ip2nation and ip2nationCountries tables added. CHECK! Booya! How you like me now?
Now the plugin was uploaded, flag pics were uploaded, tables added to the database, and all that was left now was adding the code (and of course... activating the plugin). Okay so any moron can activate a plugin. I had to figure out the code. Not being a programmer, this required a lot of reading, re-reading, thinking outside the box, and trial and error for me.
Here's one of the examples I saw:
<img alt=\"your flag\" src=\"/images/flag_" . wp_ozh_getCountryCode() . ".gif\">
Okay the first thing I notice is all the extra weird slashes in the code. So... I took them out and wound up with this:
<img alt="your flag" src="/images/flag_" . wp_ozh_getCountryCode() . ".gif">
Okay so that looks almost right, but still not quite. I adjusted the path to point to where my flag pics are and tried the code. As I had expected, it was not proper and it did not work. I wasn't even really sure what that code was, but it looked to me like your everyday HTML image tag divided into three parts, separated by periods. To me, it looked as though the img tag was broken into its three parts right at the src attribute. The first part looked to be the first part of the path and image file name. I theorized that the middle part, pulled records from one of the tables that was added to the WordPress database and added that data to the flag pic file name. The third part looks to wrap up the filename, src attribute, and img tag.
If you look at the file names of the flag pics, they all start with flag_ and end with .gif. What goes in between is the two digit country code. Using the PHPMyAdmin database editor, I browsed the ip2nation table that I added earlier, and saw all the two character country codes that go in the middle. Okay, so now it's starting to make more sense, but no home runs yet, so it's back to the ip2nation blog. I needed more help with this code.
The next example I dissected was one that Ozh said was straight from his own comments page:
<img alt="<?php wp_ozh_getCountryName(1,$comment->comment_author_IP) ?>" src="/images/flags/flag_<?php wp_ozh_getCountryCode(1,$comment->comment_author_IP) ?>.gif">
This oughta be just what the doctor ordered. But it's just More Funky Code! WTF is all that???
Geez, now my brain was hurting. I got to the point where I understood that:
< = Less Than, or <
" = Quotation, or "
> = Greater Than, or >
- etc...
So after deciphering all the funky code, I came up with this:
<img alt="<?php wp_ozh_getCountryName(1,$comment->comment_author_IP) ?>" src="/images/flags/flag_<?php wp_ozh_getCountryCode(1,$comment->comment_author_IP) ?>.gif">
That looks like a much longer img tag than I had seen before. Looking specifically at the src attribute, I saw some major differences, such as the <?php and ?> php tags. There is also some extra code between the Parenthesis (1,$comment->comment_author_IP), and probably the most interesting difference to me, was the absence of the periods that once separated the three parts of the src attribute. Until I saw this, I did not know if those periods were required or if they were just there to emphasize the three parts of the src attribute.
Once I got the code figured out, I had all the pieces I needed to add this great feature to my blog. To me, this was quite challenging, but not impossible. Perhaps if I put some time into some formal study, this stuff would come a little easier to me. Anyway, I'm gonna wrap this up. This post turned out MUCH longer than I had planned. Feel free to leave a comment to see if the right flag comes up for you.
« Hide it