You are hereProgramming & Web Design / PHP


PHP

warning: Creating default object from empty value in /home/hagrinad/public_html/modules/taxonomy/taxonomy.pages.inc on line 33.

PHP related posts.

Fixing the HTTP 500.21 Error - "Handler "PHP53_via_FastCGI" has a bad module "FastCgiModule" in its module list"

By hagrin - Posted on 10 November 2011

Recently, I have been working on several projects that I had only brainstormed for a few months and now it was time to actually start developing. One of those projects called for me to setup a new Windows 7 desktop to use PHP on IIS. After installing PHP through the "newish" Web Platform Installer from Microsoft, I tried browsing my PHP site and received a HTTP 500.21 error in my browser - "Handler "PHP53_via_FastCGI" has a bad module "FastCgiModule" in its module list".

Luckily for me, this is a very easy fix. Just follow these steps -

  1. Open up your Control Panel and go to the Programs section and choose "Turn Windows features on or off".
  2. Under Internet Information Services, select World Wide Web Services, then Application Development Features and check the box for CGI.
  3. Click OK and install.
  4. Load up your PHP webpage!

It's that easy! Good luck to everyone with their Windows based PHP development.

Installing mcrypt on a GoDaddy Linux Virtual Dedicated Server (VDS)

By hagrin - Posted on 15 August 2008

Recently, I was given a consulting project to develop an e-commerce site and I immediately thought of Magento - an open source e-commerce solution written in PHP. Magento is one of the better pieces of software that goes widely unknown by many since very few people develop e-commerce sites (as opposed to say Drupal where everyone and their kids are bloggers).

However, upon installation of Magento on my GoDaddy Linux Virtual Dedicated Server (VDS), the installation will stall on the mcrypt dependency. The mcrypt library stores several algorithms that help secure your e-commerce site's data. Unfortunately, by default, the GoDaddy VDS package does not have the mcrypt library installed. To install mcrypt, follow these steps -

  1. SSH into your VDS with your favorite SSH client or the SSH Java applet offered by GoDaddy.
  2. Login with your credentials.
  3. Su to the root user.
  4. Type "yum install mcrypt*". Say yes to the prompts.
  5. Type "yum install mhash*". Say yes to the prompts.
  6. Type "yum install php-mcrypt*". Say yes to the prompts.
  7. Type "yum install php-mhash*". Say yes to the prompts.
  8. Restart the server.

Once the server has restarted, you can re-run the Magento installation and you will be able to successfully complete the wizard.

Reading Files Using PHP

By hagrin - Posted on 14 February 2007

IBM has created yet another great tutorial this time covering how to read files using PHP. This tutorial covers such functions as fopen, fclose, feof, fgets, fread, readfile, fgetss fpassthru, fseek and fscanf. IBM masterfully breaks down each function and gives the reader a good idea what the best practice is in using each of the functions.

How To: Implementing Automatic Blog Pinging Using PHP and XML-RPC

By hagrin - Posted on 10 February 2007

Posted By: hagrin
Date: 14 November 2005

Overview:
In order to run a well-known, successful website or blog, Internet users must be directed and drawn to your site. The draw comes from the content you post and create, but how do people know about the content you have posted on such a vast cyber world? Internet based companies have identified the need to centralize data and content offerings by offering indexing services. Such services, such as Google Blog Search, Technorati and Weblogs Inc., are indexing services specifically designed to publicize blogging content. However, unlike Google's main search engine, these services do not crawl the Internet on their own to find new content. Instead, these services need to be contacted by the blog/site owner either through a manual "pinging" or by automatically pinging the service through a remote procedure call. Obviously, webmasters do not want to maintain manual processes to promote their site so automatically contacting these indexing services is preferred. The following explains how to accomplish automatic blog pinging utilizing PHP and XML-RPC.

What You Need:
To automate the blog pining process, you will need the following:

  1. A website written in PHP and a PHP installation on your web server
  2. XML-RPC for PHP class library
  3. Weblog_Pinger class library

Automation Process:
Now that you have the tools needed to complete the process, an implementation plan is needed. So where do we begin?

1) Where and when should the pinging process occur? - For the most effecient and effective result from automatic pinging, you want to choose a place in your posting procedure that ensures that an automatic ping signals new content on your site. For 99% of blogs, you will want to add the necessary code after a successful post or publishing of new content. Why? Well, simply, since your blog has fresh, new content, you will want to notify all blog indexing services immediately. However, for sites that post new content in extremely large quantities (which isn't suggested since most users will not want to sift through 50+ new posts a day), you might want to consier adding the code in an hourly cron job because you do not want your site to get delisted for abusing the pinging service and "flooding" their services.

2) The Actual Code - So, after determining that you want to add your code after a successful post/publishing of your blog, let's examine exactly what you will need to do. Most likely, you have written code (or see code if you are using a third party app) that holds a SQL Insert statement. After the SQL query code, you need to add the PHP code necessary to ping the blog indexing services. That code should look something like the following:

// After SQL Insert Code ...

require 'weblog_pinger.php';

The "require" statement should be followed by the correct path for where you saved the weblog_pinger.php file (item #3 from the "What You Need" section). In the example above, the PHP page that performs my post submissions and blog republishing is located in the same directory as my weblog_pinger.php file. After the require statement, you should add:

$pingblogs = new Weblog_Pinger();
$pingblogs->ping_all("Name of Your Blog", "http://www.hagrin.com", "", "");

So what does this code do? The first line says to use the variable $pingblogs (you can name the variable anything you want, I chose $pingblogs arbitrarily) and create a new object instance using the Weblog_Pinger class. This class is specified in the weblog_pinger.php file you "required" above. The second line uses our new $pingblogs variable and calls the ping_all function which will send your information to three sources - Technorati, Weblogs and Blo.gs (there are other functions available to call, but for the purposes of the tutorial, I chose to use the ping_all function for simplicity). After the calling of the "ping_all" function, you will notice 4 items encapsulated within quotes and separated by commas. The first item declares the name of your blog (in this example, "Name of Your Blog"). The second item, http://www.hagrin.com, specifies the URL where your blog is located. Item three, which I have left without a value, is the "change URL". This URL represents where the actual new content is located. It is not necessary to declare a change URL - the default value automatically returns the URL where your blog is located (the second item in the ping_all function). Last but not least, the fourth item holds the category your blog should be submitted into (the default value is none).

And that's it!!! You don't need any additional code to get the basic features working which are good enough to get you listed in all the blog indexing services you need to promote your content.

Resources:

  1. Workbench Blog by Rogers Cadenhead

Version Control:

  1. Version 1.0 - 15 November 2005 - Original Article

Google Data APIs Now for PHP 5

By hagrin - Posted on 01 November 2006

The Google Code blog announced the availability of Google Data API support using PHP 5 through the Zend Framework. Zend, who I know better for making one of the best PHP IDEs around, has developed their Google Data Client Library which "provides a PHP 5 component to execute queries and commands against Google Data APIs from your PHP applications".

Now, I just need to get a webshost who will upgrade to PHP 5 (not to mention, update their version of python).

Paypal and PHP

By hagrin - Posted on 05 August 2006

Zend, the creators of one of the best PHP editors, released a tutorial depicting Paypal implementation on your PHP based website. The tutorial is great for any web programmer looking to do consulting work and building e-commerce websites with Paypal functionality (I know I bookmarked this link immediately). This is a must have for the freelance PHP programmer.

Create Dynamic Images in PHP

By hagrin - Posted on 05 August 2006

Ice Melon has a great tutorial on how to create dynamic text over images. I've seen this a few times (on some *cough* non-technical websites) and have always wondered how to do it and now here's the PHP tutorial. Definitely give it a look as it may open your eyes to the power of PHP.

PHP 5.1.0 Released

By hagrin - Posted on 04 August 2006

PHP 5.1.0 has been released fixing numerous bugs and security issues.

One of the big complaints by users over at Slashdot were the lack of namespaces being included in this PHP release. The problem that this causes for PHP developers is that they have to prefix all classes used with a unique prefix. The PHP development team has discusssed how to address this issue, but there still hasn't been a namespace patch released. Persoanlly, I haven't run into too many issues with the lack of namespaces; however, my .Net experience has shown me the power of namespaces.