How to force www prefix in PHP and Asp.Net

How to prefix WWW to URL in PHP and ASP.NET

It is quite important to understand difference between URL prefixed with www and without www.

There seems to be not much difference in those as both represent same URL but this can be pain while coding some if its a bad day. It also make a difference in case of SEO and better to have uniformity in all URLs of website.

If you have adedicated server with IIS, its quite easy to force website to have each URL prefixed with www but in case of shared hosting you may be required to make some addition in code to acheive this. Here is a code snippet to force URL to prefix www in asp.net:
Continue reading

Why Hire a Consultant?

why-hire-a-consultant

Why do companies update or upgrade their systems and equipment?

One reason is to be perceived by their clients as up-to-date and relevant with current technology. Other times the motivation is to increase productivity and profitability; or to cut expense and streamline operations. Whatever the reasons, the temptation often is to decrease project expense by utilizing internal resources or hiring hourly contractors to research the various manufacturers’ products.

If you are tech savvy in a company looking for new ways to increase profitability, productivity or customer retention with technology, you may have experienced something like the story below:

The Production Manager of a major regional newspaper runs his fingers through his hair in frustration. Looking at his desktop, he realizes that, once again, he is going to be working through lunch and after hours to do his regular job. Yet again, he turns his attention back to the white pages sent by the person hired to research the new IT systems being installed next year. Composing several questions for the sake of clarification, he embarks on an email dialogue knowing that this is only the beginning of a large, quickly overwhelming task.
Continue reading

How to open multiple instance of Skype at same time

Ever faced a situation when your team member is on leave and you have to manage communication with your clients on Skype as well address support requests on his Skype? And you hate it when not being able to open second instance of it.

Well multitasking is good but a pain when need to be done at different places or desk making it hard. But you can open another instance of Skype too using Command prompt.

Here is magic command to make it easy to open and use multiple Skype ids on same laptop at same time.
[code]”C:\Program Files\Skype\Phone\Skype.exe” /secondary[/code]

Hope this helps !!

Backup MYSQL database using PHP

Backup database using PHP

Sometime we need to backup MYSQL database without access to PHPMYAdmin in scenarios when need to do this through a scheduled job. Here is a code snippet I found to backup database using PHP.

This will also allow to backup complete database or single table.

{code}
backup_tables(‘localhost’,’DB_USER_NAME’,’DB_PASSWORD’,’DB_Name’);

/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = ‘*’)
{

$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);

//get all of the tables
if($tables == ‘*’)
{
$tables = array();
$result = mysql_query(‘SHOW TABLES’);
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(‘,’,$tables);
}

//cycle through
foreach($tables as $table)
{
$result = mysql_query(‘SELECT * FROM ‘.$table);
$num_fields = mysql_num_fields($result);

$return.= ‘DROP TABLE ‘.$table.’;’;
$row2 = mysql_fetch_row(mysql_query(‘SHOW CREATE TABLE ‘.$table));
$return.= “\n\n”.$row2[1].”;\n\n”;

for ($i = 0; $i < $num_fields; $i++) { while($row = mysql_fetch_row($result)) { $return.= 'INSERT INTO '.$table.' VALUES('; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = ereg_replace("\n","\\n",$row[$j]); if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; } if ($j<($num_fields-1)) { $return.= ','; } } $return.= ");\n"; } } $return.="\n\n\n"; } //save file $handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+'); fwrite($handle,$return); fclose($handle); } {/code}

How to show post from Blogger on your website

Show Blogger content on Your Website

I was recently working on a website in Open source and blog of that site was being managed on Blogger.com, in general case when blog is self hosted on same domain or is in WordPress is become quite easy to show the post on the website. Here also the same requirement was faced where I had to show the blog post on website but from blogger.com

Initially is sounded something quite complex due to my limited exposure with blogger but once I checked the post structure it become quite easy to achieve this. I did this using MagpieRSS, a free to use open source project for converting various types of RSS feed. I support Blogger too. Step by step process to achieve this is as below:

Step 1: Download Magpie RSS

Step 2: Extract downloaded files in a directory named magpierss in ROOT of your project.

Step 3: Open PHP page where we need to display list of post from blogger and paste below code, I assume you :
{code}

{/code}
Now we have to display post data fetched from blogger:

a. If you want to display POST TITLE along with DESCRIPTION from blogger on your website, use below code:
{code}
items[0];
$content = $item[‘atom_content’];
echo “

Latest Blog Entry:
$content

\n”;
?>
{/code}
b. If you want to display POST TITLE ONLY from blogger on your website, use below code:
{code}
Latest blog additions:\n”;

foreach ($rss->items as $item) {
$href = $item[‘link’];
$title = $item[‘title’];
$created = $item[‘created’];

echo “

  • $title $created
  • \n”;
    }
    echo “

    “;
    ?>
    {/code}
    c. b. If you want to display ‘N’ number of POST TITLE from blogger on your website, a small change in above code is required and it will be as below:
    {code}
    Latest blog additions

      “;
      define(‘MAGPIE_DIR’, ‘magpierss/’);
      require_once(MAGPIE_DIR.’rss_fetch.inc’);

      $num_items = 7; // Number of post we wish to display
      $rss = fetch_rss( ‘http://yourblogname.blogspot.com/atom.xml’ );
      $items = array_slice($rss->items, 0, $num_items);

      foreach ($items as $item) {
      $href = $item[‘link’];
      $title = $item[‘title’];
      echo “

    • $title
    • \n”;
      }
      echo “

    “;
    ?>
    {/code}

    JQuery and WordPress

    JQuery and WordPress

    If you are trying to add your own jQuery code to WordPress, and have had the error “$ is not a function” show up on Firebug, here is the fix:

    Convert all dollar signs ($) to ‘jQuery’
    The dollar sign is reserved in WordPress for the Prototype library, which is why it errors out. For example, instead of:

    $().ready(function() {
    $(“#select_me”).show();
    });

    Change it to:

    jQuery().ready(function() {
    jQuery(“#select_me”).show();
    });

    MX record settings for using Google apps

    Since I starting using Google app, I feel traditional webmail not much efficient in terms of usage. Yes I do admit I have become a huge fan of Google apps and for same reason I have suggested and implemented it for most of my clients.

    There are several reasons to use Google apps to enhance you business:
    – No more need to worry about Microsoft Outlook, office license etc.
    – No need of any additional backups of server as you can surely rely on Google for that
    – Seamless integration of users for an organization/business
    – Overall it very easy to use because of it interface, which most internet users are already aware of being a Gmail user

    The only thing I mostly need to search every time I configure is MX records for using Google apps, to make it more handy and easy accessible (also for your help, if required) I thought to add it on blog and avoid searching each time:

    We need to update MX records as below:
    Priority Mail Server
    1 ASPMX.L.GOOGLE.COM.
    5 ALT1.ASPMX.L.GOOGLE.COM.
    5 ALT2.ASPMX.L.GOOGLE.COM.
    10 ASPMX2.GOOGLEMAIL.COM.
    10 ASPMX3.GOOGLEMAIL.COM.

    Dont forget to select ‘Remote Mail Exchanger’ to avoid routing issues