Archive

Posts Tagged ‘wordpress’

Exec-PHP Not Displaying Categories or Archive List

March 8th, 2009

I’m currently in the process of converting one of my old sites from Moveable type to Wordpress. The site hasn’t been updated since 2007 and all the pages were static pages. I decided to port it over to wordpress and make it dynamic by getting offer information from a database.

I decided to store the offers in a database because in the past, I would get calls from the networks telling me that the wording on a page was incorrect and that I had to change it before a specific day or my affiliate link would be deactivated. This meant that I had to go to every page where the offer was listed and manually make the corrections on each page.

With the offers now stored in a database, I can just make changes in one place and the information will be automatically updated on all the pages where the offer is displayed.

Exec-PHP Plugin

With a standard installation of Wordpress, you are not allowed to include any php code in any of your posts or pages, unless you get sometype of plugin which will allow you to do so. I decided to go with the Exec-PHP plugin by Sören. There are other plugins out there that get the job done, I just settled on this one based on the number of downloads it had compaired to the others.

The plugin works great. I was able to query the mysql database and display the information within a wordpress post or page. The only problem was that when queried the database using php, my category list and archive list would become empty. I didn’t know exactly what was causing it or why. I checked everything that I could possibly check to find out what was causing this. I checked the code for the sidebar, checked my php code, checked the template code, nothing.

After scratching my head for hours, I finally figured out what was causing this. It was happening because the user name and password that I used to query my offers database was the same username/password that wordpress used to run the site.

Since my code was executed first, I was able to connect to the database and get the information that I needed and then close the connection. Once I closed the connection, wordpress no longer had a way to get the information about the categories and posts, so it displayed nothing.

The moral of the story is this:

If you use the exec-php plugin for wordpress to retrieve information from a database, make sure that you do not use the same database username that you’re using to run your wordpress site. Create a different user to use with the exec-php plugin.

Uncategorized , ,

I Upgraded and Moved

March 30th, 2008

Since its official release, Wordpress 2.5 has already been downloaded 100,000 (as of this writing, it’s only going to increase by the time I finish writing this post). I also downloaded a copy and upgraded this blog to version 2.5. I haven’t really used the new version much, but I can tell you that it looks really nice.

Installing version 2.5 is pretty easy, just make sure you backup your blog before doing so!

Changing Hosts

In addition to upgrading to Wordpress 2.5, I also switched hosting companies. This blog, and some other sites of mine used to be hosted by Westhost. The majority of my sites, including this blog is now hosted over at HostGator . I made the switch to Hostgator for a number of reasons:

  • Price - Hosting at Westhost was simply costing me too much; I’m not saying that it was a lot of money (I believe I was paying $12.50 per month), I just think that other hosting companies were offering way more features and services for half the amount. With Hostgator, I’m now on the Baby Croc plan which is costing me $8 per month. I can host unlimited domains, unlimited emails, and unlimited databases. I definitely think it’s worth the move!
  • Speed - This is one of the main reasons I’m leaving WestHost. Uploading and downloading data via FTP very slow! Seriously, it takes about 15-20 minutes to upload the entire contents of a wordpress install. With Hostgator, it takes me no more than 6 minutes. On top of the slow transfers, the connection would often break during mid transfer, causing me to start all over or to upload one directory at a time.

Moving the site from Westhost to Hostgator wasn’t hard at all. At first I was worried since I’ve never moved a wordpress installation before, but in the end, it was fairly simple.

The first thing I did was back up the wordpress database. Backing up the database was extremely easy thanks to the detailed instructions provided by the folks at wordpress.org. Once I had the database backed up, I proceeded to back up my entire directory structure. It is important to also backup the directory structure; the wordpress database doesn’t contain any images, themes, or plugins you’ve uploaded.

Once everything was backed up, I created a new mysql database on my hostgator account and also added the domain to my account. When you create the new database, make sure that you update your wp-config.php file to reflect the new mysql database name and connection information (if it changes). Once the database was created, I did an import of the database. Once I did that, I just needed to change the DNS information to point the hostgator name servers instead of westhots’.

So it’s official, I’m running on hostgator servers, and I like it!

BTW, Wordpress 2.5 was downloaded 761 times in the time it took me to write this post. So what are you waiting for, download Wordpress 2.5!

Other , ,