// archives

php

This tag is associated with 1 posts

Solved: Extension filename.php not present

The day was pleasant till I got an E-mail from a client with a PHP script file attached to it. I had to schedule the PHP script via Cron on a Linux server. For PHP scripts in Cron, I do not prefer writing the Cron job as:

1  30  *  *  *  /usr/bin/php -q /opt/script.php

Instead, I prefer a crisper line as:

1  30  *  *  *  /opt/script.php

The latter is obviously neater and readable. To prepare a PHP script to execute just by the filename, you need to do two things:

  1. Add a line to the path to the PHP interpreter at the top of the script. For example:
    #!/usr/bin/php -q
    <?php
    // PHP code
    ?>
  2. Make the script executable as:
    chmod + script.php

Before inserting it in Cron it is always a good idea to test the script by executing it manually as:

/opt/script.php

What always worked for me, failed on me this time with an error saying: Extension /opt/script.php not present. What will you do when you get an informative error (being sarcastic) like this? I too had no clue. Read the rest of this entry »

GD Star Rating
loading...
GD Star Rating
loading...

Twitter Updates for 2010-04-12

GD Star Rating
loading...
GD Star Rating
loading...

Twitter Updates for 2010-04-12

GD Star Rating
loading...
GD Star Rating
loading...

Drupal 6: Different Page Templates for different Content Types

Given the flexibility of Drupal, a different page template depending on the Content Type is not very demanding. The good news is, it is very much possible. The bad news is you may have to struggle like me to find the simplest, neatest and working method to achieve it.

Reading the documentation and Googling would result in many methods – some are confusing, some are not so neat and others apply to earlier versions of Drupal. Following is my favourite method to setup different page templates, depending on the Content Type, in Drupal 6. Read the rest of this entry »

GD Star Rating
loading...
GD Star Rating
loading...

Twitter Updates for 2010-03-07

  • My article on Monit (an open source systems monitoring & repair tool) in PCQuest magazine (March 2010) http://short.to/1a4av #
  • Never complained/fought with neighbours 4 parking. Friend told: now they try 2 park their/visitors cars such that I get passage @ late nite #
  • Prado http://short.to/1a4cm PHP framework for ASP .Net developers. .Net Developers have coded Prado apps referring to MSDN docs! #
  • Microsoft Hyper-V drivers for RedHat 5.x http://short.to/1a4w0 #
  • Updated my Android Dev Phone 1 (ADP1) to Cyanogen ROM 4.2.15.1, over the air, using CM Updator app @cyanogen #
  • Swipe keyboard trace does not seem to work with ADP1 1.6 + Cyanogen Mod. Anyone else got it working on ADP1? #Android #
  • The anticipation may be making you crazy now that go-getter Ma… More for Leo http://twittascope.com/twittascope/?sign=5 #
  • Thanks to @cyanogen and no thanks to @htc or @google that my Android Dev Phone 1 #ADP1 is still getting updated #
GD Star Rating
loading...
GD Star Rating
loading...

Twitter Updates for 2010-02-03

GD Star Rating
loading...
GD Star Rating
loading...

Web Scraping with Firefox and PHP, using XPath

Last year, I faced two projects which required automated Web scrapping – to aggregate content from web pages. I evaluated different methods for Web scraping with varied level of success. Thanks to the changing structure of Web pages, non well-formed pages and URL redirects.

Amongst using regular expressions and DOM (Document Object Model) parsing, I used XPath too. XPath works great for well-formed Web pages. Read the rest of this entry »

GD Star Rating
loading...
GD Star Rating
loading...

Twitter Updates for 2010-01-24

GD Star Rating
loading...
GD Star Rating
loading...

Drupal Views: Hide or display alternate text for 0 (zero) comments

I have been playing with Drupal Views extensively for the last three months for a Website project. Whenever I overcome a hurdle with Views, I end up realizing how powerful and flexible is the Views module. It is just me who doesn’t know all the syntax to tap it’s power. Here is one such example. With about four lines of code, I was able to get rid of an annoyance in an otherwise neat-looking View.

For the Website project, I built a View to show the recent blog posts along with their title, author, post date and the number of comments. All looked fine expect the comments. It pinched me to see “0 comments”, in the View, against the posts, which did not have a comment. Read the rest of this entry »

GD Star Rating
loading...
GD Star Rating
loading...

Joomla: Hide breadcrumb on the Home page

Typical requirement this is. You want to display the breadcrumb on the top of every page but the home page – also called the default page or the frontpage in Joomla. This is because you don’t just want the text “HOME” hanging on the top of your Joomla’s home page.

The “Home” may be already highlighted in the main menu, visitors know that they are on the home page and the breadcrumb is not aiding any navigation. Unfortunately, the breadcrumb module (called mod_breadcrumbs) in Joomla 1.5 does not provide any option to hide it on home page and show it on other pages. Read the rest of this entry »

GD Star Rating
loading...
GD Star Rating
loading...