Tag Archives: Programming

Web Programming

Years ago I started programming in ASP (Active Server Pages). This was a great language and was fairly easy to migrate into. However, the “cost of inclusion” was rather high as it is a Microsoft language and required (of course) that you be hosted on a Microsoft platform server. Then Microsoft decided to upgrade ASP to ASP.net.

At that point they lost me. With the advent of Linux and the world of open source it just did not make any sense to stick with something that required so much overhead. Another key downside was the database programming required either SQL Server or MS Access. One was too expensive and the other not robust enough.

I switched to PHP and MySQL and I have never been happier. It is easy to find a hosting company that supports these languages and there is a wide realm of support and samples for both. If you like web programming PHP is a must to check out.

And of course the ever popular WordPress platform is PHP based.


WordPress Excerpt Plugin

I created this little plugin for my own use, and after reading today’s post over at HackWordPress.com it reminded me that Garry Conn had asked me if I was going to publish it, so here it is.

I like to use the the_excerpt() instead of the_content() in several places on a blog. However, I did not like the fact that the_excerpt was only showing 55 characters. I could change it in the WordPress code, but then everytime I update the blog with a new version of WordPress I have to remember that the change is there.

CyberExcerpt is simply a copy of the_excerpt routine in a plugin. The advantage to this is I can change the_excerpt length, turn on the plugin and I have my solution, a longer excerpt.

If you want an excerpt with a length other than 55 characters, just download the zip file, unzip, and then upload the CyberExcerpt folder to the /plugin folder and change the value in line # 24, then call the_excerpt() as you normally would.

$excerpt_length = 100;

Download CyberExcerpt

WordPress XML Parsing Error

No sooner did I write the post about troubleshooting I came across a WordPress error that took way more time to solve than I expected.

One thing I know as a programmer is that every single character in a file is critical. I can not even guess how many times a simple question mark or apostrophe has caused me to lose hours of time trying to find. And here is a perfect case of troubleshooting a WordPress error that was so simple, yet so hard. The error was an XML Parsing Error.
I have a new site (NonPartyPolitics.com) that I have been working on and I realized the RSS Feed was not displaying, the following error was popping up.

XML Parsing Error

Looks pretty obvious, there was an error at line 2, column 1. Step one was to see what was happening, so the first thing I did was look at the source of this page. Nothing jumped out at me, so I loaded a working WordPress site, pulled up the RSS feed and looked at the source, I placed the 2 files side by side and there it was. On the feed with the error there were 2 blank lines before the code. Interesting. I then pulled up the home page for both sites and the same thing, there were 2 extra blank lines on the home page source. This told me that the problem was probably not in the RSS code, but it could still be in the code somewhere.

The next logical step was thinking of what I changed last. I really had not done much outside the template except installing a couple plugins. So, I turned off all plugins. Now the hard part was having a little patience. I could see that on the home page the 2 blank lines were now gone, but I had to edit a post and wait for the feed to catch up.

Sure enough that was it, 2 blank lines were gone in the feed. Now, which plugin?

Here is a little logic for you, if I have 2 blank lines, and I know a plugin is causing it, all I need to know is which plugin is issuing 2 extra carriage returns. The key to this is to know that I was not looking for the plugin actually writing the blank lines, I was looking for a plugin with 2 extra carriage returns. And I found the culprit.

I am not going to call it by name because the plugin worked fined on other sites and it did not download from the original like this. Either I did something to cause this problem, or it was just a fluke.

Here is the plugin before I fixed it…..

Plugin1

and here is the plugin after the fix…

Plugin 2

So there we go, a real WordPress troubleshooting case solved. All of that because of 2 extra carriage returns.

Make sure when you are working with code you are aware of every character and every space!

Learn to Troubleshoot

Over the last 20 years I have probably made more money from troubleshooting than anything else. Troubleshooting is the key to doing any type of repair or maintenance work, in any field.

In most cases software is developed to solve problems. Some problems are just to increase productivity or make a process easier, but solving a problem is the start of almost all development. And since blogs are nothing more than CMS software to allow the non programmer to develop their unique “weblog” or “website”, the processes are the same.

“A problem well defined, is half solved”

When you are faced with a problem on your blog I would recommend a few simple steps.

  1. Keep a backup of your files. I use a 4 GB thumb drive, and I File Sync it to a folder on my PC drive. That way I have 2 copies at all times.
  2. Before you change a file, make a copy of it. I usually make a copy and clearly mark it. If I am changing single.php I will copy it using the original name and current date, such as, single-20070110.php. On a desktop PC the easy way to do this is right click, copy, paste. The OS will automatically name the copy as such. This makes going back a snap.
  3. What was the last thing you changed? 9 times out of 10, a simple change can cause an unexpected problem somewhere else. If you keep track of your changes (see #1 & #2), it will be easier to “backwards engineer” the problem. Undo the last change and see if that caused the problem.
  4. Google it, I know that sounds like a cliche these days, but it works. I use the Google Groups search for most problems, the idea is that someone has asked the question before, and there has probably been an answer given in the groups.
  5. Ask someone you trust to “think with you”. Two heads are better than one, and sometimes a fresh look from another person will result in a quick diagnosis.
  6. Pay someone to “think for you”. In most cases the last resort is to hire someone to help you. Of course, this could be moved way up the list depending on your budget, schedule and expertise. But, if you can afford to do this, maybe you should have hired someone to make the changes for you.

Making changes and making mistakes is no reason to have everything crash on you. If you keep backups and keep track of changes, most problems can be solved rather quickly. And if they can not be solved, you should be able to at least step back to where you were before you had a problem.

I look forward to learning any tips you have! Just drop a comment and share with everyone.

WordPress Plugin RSS

During my Blog reading this morning I came across a post at Garry Conn dot com about increasing comments using your RSS Feed. This was right after I had watched a video at ShoeMoney.com about “What is your edge?”

The combination of these 2 posts inspired me to write a WordPress Plugin today to add Comments and Tags to my RSS, and to be a little different in the layout. The CybersFeedTags plugin will place the Tags and Comments at the top of each post in the feed.

This is a very, very simple WordPress Plugin. It should be a good learning process for anyone interested in seeing how a plugin works. There are only 9 lines of actual coding involved.

Check it out and let me know what ya think!

Download CybersTagFeeds here.