Monthly Archives: March 2013

Hiring Virtual Workers

When you need a project done, there is nothing more discouraging sometimes than finding the perfect person for the job. Virtual workers are in abundance, but finding the right one is often a trick that takes time and trial and error to to get right.

The best site out there in my opinion was Unfortunately, they were recently bought out by who doesn't quite meet up to the standards Vworker did as far as ease of use of their site and reliability of their worker pool.

The above are two main reasons I decided to start a site called that will facilitiate employers and workers both seeking to work virtually from the home or office. I modeled the site, not after Vworker, but with the same principals in mind. I concentrated foremost of ease of use and allowing only quality workers into the worker pool. The workers will be tested on every category they would like to work under, so employers are sure to get a worker who knows the subject matter at hand.

How to scale down images using Gimp

I did some experiments today on taking a larger image and converting it to an icon image that was 16px by 16px when the original image was 128px by 128px. There are different ways to re-size an image and I will discuss some of the pros and cons of each way and show you the results of what I found to be the best method for scaling down an image.


Method 1 - using the width and/or height attribute of the img tag. This method produced the 3rd question mark icon in the above image.


  • You don't have to open the image and re-size it in an image editor such as Gimp or Photoshop.
  • Saves time


  • Take up more disk space on your website because obviously a smaller image will take up less memory on your server, so by leaving it large and scaling down in the img tag, you still have to load the larger image into memory.
  • Longer page load times - since it has to load the larger file size into memory to show the webpage in the browser, it does effect the page load time negatively.
  • More code - it may not add much, but if you like to use a minimalist strategy when it comes to HTML code, you do have an extra attribute or two in the img tag when using this method.

Method 2 - re-size the image in Gimp or another image editor to the size you want to display the image on the web page. The 1st question mark in the above image was done with this method.


  • Saves disk space on your server because smaller images equal smaller file sizes in general
  • Faster page load time because of smaller file size.


  • More work and time to develop because you have to open the image in the image editor and scale it down which I will discuss later on in the tutorial if you choose this or the next method described.
  • Loses a little clarity in many cases, but if you are good with an image editor, you can compensate for much of this. read on to learn more.

Method 3 - Re-size the image about half way to the size you need or depending on the original image size. For example if your original image was 500px by 500 px, you will want to scale it down more than half way. If I wanted a 16px by 16px icon, I would scale it down to 50 by 50px. The last or 4th question mark in the above image was done using this method and looks the best to me.


  • Probably overall, the best method because it saves a reasonable amount of disk space and load time while looking better than method 2 and almost as good if not better than method 1.
  • Looks clearer than when you scale down to small.


  • As with method 2, you still have to open the image in an image editor like Gimp or Photoshop to scale it down, but that only takes a few minutes and saves you valuable page load time and disk space especially when you have too many images on your web pages.

Best Method

So as you can probably deduce from my writing above, I recommend method three described above. But let me elaborate on how to do it so that the image looks good using Gimp to scale down the image size.

How to scale down an image with Gimp

  1. Open the original larger file using Gimp.
  2. Click on "Image" in the top tool bar.
  3. Click on "Scale Image" from the "Image" drop down.
  4. For an end result of a 16px square icon, scale down the width and height to 50px in the resulting "Scale Image" pop up that appears.
  5. Make sure the x and y resolution are set to 72 pixels/inch as that is what looks good on a webpage from the experiments I did and from what I have read elsewhere.
  6. Change the "Interpolation" to "linear". I did this because the default setting of cubic didn't produce as good of results, but you might want to try both because it may depend on the image and the amount you are scaling it down. If you look at the example image with the question mark icons above, the second question mark was done using "cubic" and the fourth was done using "linear", so you can see a minor improvement in my opinion.
  7. Export the image and save it as a .png. I have found the the .png format works best for smaller images. It also is great for transparent backgrounds.
  8. Now install the image in your webpage using the img HTML tag and the width attribute to scale it down to the final size of 16px square. You do not have to set both width and height. If you set one or the other, the corresponding opposite setting will scale accordingly so save some code and only set one or the other unless you want to skew the image for some reason by giving them different values.


That's it, I hope you learned something here. I spent a good hour or two learning the beset practice, so thought I would document it for future reference here for anyone who needs it.


Finding the right domain name

Finding the right domain name takes patience, time, research and knowledge. I will help with some tips for those of you who are seeking to buy a domain name for your website or to buy several to add to your domain portfolio.

Domain name finding tips

  • TOOLS - use online tools to assist you. There are all sorts of tools that can help you pick the right domain name for your needs. See my list of tools below for more information. If you are a serious domainer, have someone like me build custom tools for you because all of the real good tools are kept secret and have been custom made for domainers like you. If you spend a little money you can have a tool developed that can find you great domain names on a regular basis. I build tools for domainers that can cost anywhere from $50 to $500 depending on how complex they are to code, but most cost under $200. Email me at if you want me to build a tool for you.
  • Don't always buy a new domain name. While new domains are inexpensive, often around $7, they have no traffic which makes them worthless and means you will have to do a lot more seo work than if you bought one with traffic already.
  • Research - check a domain name for traffic stats, overture score, dmoz, google, etc

Tools for finding a domain name:

  • Bulk Domain Availability Checker I like this tool because you can write out a whole list of domain name you like and paste them into the textarea provided and it will tell you not only if the domain names are available, but if they have been registered before as well. I like to take a good look at ones that have been registered before to see if they have existing traffic still which can make them valuable.
  • Domain Stats Checker is a good tool for checking to see if the domain is really good. It will not list data on domains that do not have a significant history, but if you happen to stumble across a domain name that has stats with this tool, chances are you found a winner.
  • Way Back Machine is a tool that lets you see what the website, if any, looked like in the past for any domain name they have records on and they have records for many.
  • domain registrar - once you find the domain name you want to buy, you have to make the purchase which can be done through any of the big domain name registrars such as, but I linked this one,, because they had a promo at the time I wrote this post for $0.50/year domain name registration! Good luck, it may not be there by the time you read this, but give it a shot, otherwise, just go with Godaddy who is normally the cheapest or close to it.
  • Alexa Rank Checking Tool - allows you to check up to ten domain names at a time to see if they have an Alexa ranking. My suggestion is to buy any cheap domains with an Alexa rank listed.
  • Back Link and PR checker - checks one domain at a time for PR rank and back links.

Solution for PHP Mail Function not working

There are several reasons why PHP's Mail function might not work, but I discovered a trick today that worked for me so thought I would share. I am on and at first I thought they had the mail function deactivated. By the way, that is one thing that can stop mail from working, so check to make sure the mail function is not set up wrong in your php.ini file if the below trick doesn't work.

Command simple PHP mail functinon example

This is the one that works on most servers, but didn't on mine, so if the following code doesn't work for you, read the next example. Here is the simple PHP mail function test script:

//send an email using PHP's mail() function:
$to = '';

$message = " eml5.php";

// If lines are more than 70 characters, use wordwrap():
$message = wordwrap($message, 70, "rn");

// Send
if(mail($to, 'test email subject', $message)){
echo "<p>Email was sent!</p>";
echo "<p style='color:red'>ERROR! Email did not send...</p>";
If the above doesn't work try the next simple script with a minor twist.

Alternate PHP Mail Example

I found out that by adding the NULL value followed by the -f parameter which indicates the from email address, that it enabled the mail function to work on one of my servers that it never worked on before, so try this if you have a similar issue:

//send an email using PHP mail() and -f param:
$to = '';
// The message
$message = " scriptname.php";

// wrap lines larger than 70 characters:
$message = wordwrap($message, 70, "rn");

// try to send email:
if(mail($to, 'test email subject', $message, null,
echo "<p>Email was sent!</p>";
echo "<p style='color:red'>ERROR! Email did not send...</p>";
//return user back to search_jobs pg:
In the above example, I found that the email address following the -f parameter had to be registered with my hosting provider as an email set up from my Cpanel, but this solution worked for me when no other one would, so hopefully it will help someone else as well.

Adding List of All Posts to WordPress Sidebar

In this tutorial, I will show you the method I used to add all posts to my sidebar. You can see the code in action to the right of this page.

Simple method to include all posts in WordPress sidebar

The easy method that I first used was just to use the wp_get_archives WordPress function with defaults. To do this, simply add the following code to the top of your theme's sidebar.php file:

<h2>All Posts:</h2>
<?php wp_get_archives('type=postbypost'); ?>   

Adding custom post list to WordPress sidebar

I decided I wanted my list styled to my needs however and ended up with the following code to get what you see in the sidebar of this page:

<h2>All Posts:</h2>
 <?php $args = array(
    'type'            => 'postbypost',
    'limit'           => '',
    'format'          => 'custom',
    'before'          => '<li>',
    'after'           => '</li>',
    'show_post_count' => true,
    'echo'            => 1,
    'order'           => 'DESC'
); ?>    

 <?php wp_get_archives( $args ); ?>

The above code demonstrates all the possible arguments you can use with the wp_get_archives function. I wanted an ordered list and the default HTML type shows a list without numbers, so I changed it to custom and used the before and after arguments to place li tags before and after each post title and surrounded the function all with ol tags to complete the layout.

Problem Inserting Data into MySQL Database with PHP

If you are working with MySQL and PHP, chances are you have come across an error that looks something like:

Error in inert to users table query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's cats name','Trouble')' at line 1

The trick to figuring out the above error is to take what you see directly after the word "near". That very next character is most often the culprit and the reason why your query failed. So, as you can see in the above error, the first character after the word "near" is a single quote. If you have worked with MySQL long, you may know it has issues with quotes. MySQL has a functnion for this already in PHP called the mysql_real_escape_string function. I know, nice long function name that is not so easy to remember, but that's what we are dealing with. In MySQL, you have to escape single quotes to enter them into a table. Rather than writing a function to escape any form input you might be collecting, you can use the PHP function already provided as follows:


$first_name = $_POST['first_name'];

That is probably how you are currently collecting data from your form elements if you are getting the above error. Here is what it should look like using the mysql_real_escape_string PHP function:

$first_name = mysql_real_escape_string($_POST['first_name']);

Try your query again after replacing the PHP code that collects the form value and see if the error goes away. It should.


DO you have a huge file that needs the mysql_real_escape string added, use your text editor's find & replace feature. If you are using notepad++, for example, click search, then replace, the for the search and replace popup's field, enter:

Find what: $_POST['

Replace with: mysql_real_escape_string( $_POST['

Wait, your not done there, next do a final search and replace using:

Find what: '];

Replace with: ']);

The second search and replace adds the closing comma to your function, making it complete. Be careful if you use replace all. I generally use "replace" and "find next" buttons to do one at a time so I don't inadvertently replace any unwanted code. It is still a lot faster than typing in that long function name a hundred times.

Another Tip:

Is mysql_real_escape_string not working or throwing an error? If so, I may have a solution for you. Often, the reason for this to happen is because you have to include a database connection string before you can use the function since it is a mysql function as well as a PHP function. It won't work until you include your database connection string or file.



How to Add a File Download Link to WordPress or any Website

Some files naturally download with a regular link tag, but what do you do if you want to provide a link to a PHP file for users to download? This is the solution I used. It can be used to download txt files or other file types as well. Experimentation is your friend.

Add the following code to a file named downloadPHP.php:


$filename = $_GET["fnm"];//add your own validation here.
  header("Content-Type: application/octet-stream; ");
  header("Content-Transfer-Encoding: binary");
  header("Content-Length: ". filesize($filename).";");
  header("Content-disposition: attachment; filename=" . $filename);


Save the file as downloadPHP.php and install it in your WordPress root directory or in your website's root directory if you are not using WordPres or if it's just easier for you that way.

In your blog post write out your link text using the WYSIWYG editor then select that text and click the link symbol to add a link and add something like:

Replace with the URL to your blog and replace your_filename.php with the file name you want to download and place the file you want to download in the same directory as the downloadPHP.php file or include a path to it with the file name.

or if not in wordpress, simply add the following link tag to download using the above suggestions for changing the format:

<a href="">Dowload PHP file</a>


Do not replace the "fnm" variable in the link above and the PHP code above that with anything that could be an "filename" variable in php such as:




I first used "thefile" as the get variable passed to the downloadPHP.php script and it didn't work because evidently that's a reserved variable name which I didn't know. I knew "filename" probably was and "file", but "thefile" didn't seem likely. Live and learn.


This script comes with no promises or guarantees and you must use it at your own risk. That said, it is a security risk, so you are responsible for creating your own validation code and security measures if you use this script. The above code is a bare bones style infrastructure meant as a learning mechanism only and needs further precautions in place in a live online environment. So, be careful. It could be exploited by a hacker with malicious intent the way it is.


How to Build a QR code Generator in PHP

This tutorial will teach you how to build a QR code generator with just HTML and PHP. The version of the QR code generator we will make here is for encoding URLs, but can very easily be modified to encode plain text, phone numbers, GEO codes, SMS messages and more. The buildQRcode class allows for several different encoding methods, but the front end I am building here is for encoding URLs, so if you have a need to encode something else ,simply make the changes to the simple front end script that apply. You can determine those changes from examining the buildQRcode class in buildQRcode.php which you can download using the link provided below. Let's get started...

Preview of QR code URL Encoder

Click to view working example

Example QR Code Encoder Output

This was generated using the code below:

QR code

Instructions for building a simple QR code generator:

First, download the buildQRcode.php file from my server here: Download from

Next build the front end PHP script using both PHP and HTML like I have done below:

<div align="center">
<h1>QR Code Generator</h1>

<form id="theform" name="theform" method="post" action="">
URL to Encode: <input type="text" id="jafty" name="jafty" value="" />
<br /><br />
QR Code Image Size:<select id="sz" name="sz">
<option value=100>100px by 100px</option>
<option value=150>150px by 150px</option>
<option value=200>200px by 200px</option>
<option value=250>250px by 250px</option>
<option value=300>300px by 300px</option>
<option value=400 selected>400px by 400px</option>
<option value=500>500px by 500px</option>
</select><br />
<br />
<input style="text-align:center;" type="submit" id="sbmt" name="sbmt" value="Generate QR Code" />

//proces when temp card button is hit:
echo "<p align='center'>Your URL Data is encoded in the below QR code:</p>";
//include QR code class
include 'buildQRcode.php';
//create buildQRcode instance
$qr = new buildQRcode();

$encodedData = $_POST['jafty'];

$qr->link($encodedData);//change link to text to make this into a text encoder.
//specify size and get link to image
$QRsz = $_POST['sz'];
$QRsrc = $qr->get_link($QRsz);
echo "<p style='text-align:center'><img id='QRimg' src='".$QRsrc."' border='0'/></p>";
}//end if form submitted.

There you have it, let's look at what we did. I wont bother explaining the file you downloaded, but the above code is what's important for you to build your own qr code generator.

First I developed the HTML code at the top of the file. A simple form to collect the URL and size of the image to generate, bare essentials.

In the PHP code after the block of HTML, the first line following the opening PHP tag is to determine if a user submitted our form. The next line of PHP after the comments is to include our class that's in the downloadable file from above. After that, we create our buildQRcode instance and set the encodedData variable to the value of the URL field in the form . Then we call a function from the buildQRcode class, set the size and get the link. Finally we echo an img tag to show the QR code image in our webpage. It seems pretty simple from this point of view because all of the hard work is done in the include file, but that's a whole different tutorial. Have fun playing with your new QR code generator!

Scanning the Generated QR Code

when you build your encoder and test it, you can either use an app on your iPhone or iPad to read it or if you don't have that luxury, use an online QR code scanner like the one at:


How to get last inserted ID from MySQL with PHP

Here is a simple method for getting the last inserted ID of a row after doing a MySQL insert. I find this handy for when you need to know a user's ID when doing user registration scripts. Sometimes you need the ID to pass on to the next page to do an update on the same table or store the ID in another table for example.

mysql_query("INSERT into table (name,address,etc) VALUES('$name','$address','$etc')") or die(mysql_error());

$getID = mysql_insert_id();

Another way to do the same thing is by replacing the last line above with:

$last_id= mysql_result(mysql_query("SELECT LAST_INSERT_ID()"),0);


There are some things to watch out for that can cause the above code not to work. For example you have to use a mysql_close() before the insert statement if you use more than one connection in the script. Also you have to have an auto increment set up on the table that you do the insert on or it won't work of course.

How to get a Definite IP address for a site User

Here is a PHP function that is more reliable in getting your site visitor's IP addresses. It checks all sorts of little known about PHP environmental variables and returns the actual IP address even if a user is behind a proxy server.

function IPaddy() {
        if (array_key_exists($key, $_SERVER) === true) {
            foreach (explode(',', $_SERVER[$key]) as $ip) {
                if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
                    return $ip;

echo "<h3>Your IP address is: ".IPaddy()."</h3>";


How to do a MySQL Update with PHP

Here I will demonstrate how to do a MySQL update using PHP.
$con = mysql_connect("localhost","user","passwrd");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("my_db", $con);

mysql_query("UPDATE table_name SET field1 = 'value1', field2 = 'value2'
WHERE field3 = 'whatever' AND field4 = 'whatever'");


That's it! pretty simple really. You will learn to remember these your own way as I have after years of using them, but for now, you may reffer back to this tutorial anytime you need to do a Mysql Update with PHP.