I’m top 2% …yeah, I rock!
It’s been while since I added a blog post. Mostly because I haven’t really had time. I’ve been….. working! lol
Anyway, I checked the standings today, and I am ranked in the top 2% of my field on elance, which is pretty awesome. Work has become much more regular, and I rarely bid on projects anymore. In fact, in the last thirty days I’ve probably bid on maybe 4, total. My income is steadily increasing and I have made some great connections for outsourcing my overflow. Business is good! My personal life is good too, but I wont go into that here
Look for some new articles in the next few weeks!
Peace & Love Beautiful People!
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
testing php inside a post
This post uses an external calculator I created for a client. I’m testing the wordpress php plugin
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
Building Dynamic Queries
When working with a database, you’ll sometimes find yourself in a situation where you don’t actually know what the query will consist of beforehand. One situation where I encountered this was on www.bleggierealestate.com. I was building a property search system and the query really needed to be dynamic, otherwise I’d be sending a bunch of junk info to the server, and producing incorrect results. So, I turned to dynamic querying.
What a dynamic query is, is basically a search string that is dependent on user input. What you’ll be doing is building your query in parts. For our example, we’ll be searching for a person in a database with specific attributes.
let’s say our form has five fields:
- height
- weight
- age
- eye-color
- hair color
We’ll start the query off like this:
$query = "Select * from people where ";
Now that we have the beginning of the query the next thing we have to do is decide which options the person used to seach, and build the query accordingly:
if (isset($_POST['height'])){
$query .= "height='". $_POST['height'] . "' AND ";
}
if (isset($_POST['weight'])){
$query .= "weight='". $_POST['weight'] . "' AND ";
}
if (isset($_POST['age'])){
$query .= "age='". $_POST['age'] . "' AND ";
}
if (isset($_POST['eye-color'])){
$query .= "eyecolor='". $_POST['eye-color'] . "' AND ";
}
if (isset($_POST['haircolor'])){
$query .= "haircolor='". $_POST['haircolor'] . "' AND ";
}
All we did there was use some if statements to see which variables were set, and add which ever ones were set to the query (not the “.=” that appends to the end of the variable instead of overwriting it).
After our if statements we are complete, we have built our query and we can execute it like normal:
$result = MySQL_query($query);
And there you have it… I hardly work a project without having to use this, these days. It’s a great tool!
Peace & Love
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
Disabling form submit on keypress
By default, forms submit when you hit the enter key inside of an input field. This is a pretty helpful feature most of the time, but there will be times when you want or need to disable that functionality. I just had one of those issues on a recent project and wanted to share the solution I found.
First thing you need is a function to escape the keypress event:
function nokeypress(e)
{
var pressedkey;
if(window.event)
pressedkey = window.event.keyCode;
else
pressedkey = e.which;
return (pressedkey != 13);
}
The second thing you need is to add a call to the function we just created in the “onkeypress” event of the input field:
{input onkeypress="return nokeypress(event)" name="textbox1" type="text" }
That’s it!
Happy Coding!
Owner/Operator
Vaughan Freelance Svcs
Escrow vs. Deposit
This is an issue I come across a lot. If you use a payment system, like elance, that allows for escrowing funds, sometimes clients will insist on escrowing. Now, there’s nothing wrong with escrowing (I use it a lot), but it is not a replacement for a deposit in hand.
Remember that the purpose of a deposit is to create a financial commitment on the part of the client, as well as help to cover any overhead during the duration of the project. Escrowed Funds simply do not meet this burden. Clients are more comfortable with escrow because they can see the money, they know you can’t touch it unless they say so, and it’s really sort of a half-commitment on their part.
Never accept escrow as an alternative to a deposit. If you agree on a job and the terms include a deposit, then get a deposit. clients may be reluctant, but I find that a client who won’t pay a deposit is more often than not pretty flaky when it comes to paying out at all… they want you to work to bring their idea to life, and they “they’ll see” how it goes… That’s not good business….
Get a deposit!
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
Don’t be afraid to ask for money!
Today we’re talking about the best and worst part of the job… getting paid! I say best and worst because, believe it or not, there will be clients who don’t wanna pay you, or take a long time to get payment out, etc…. and that sucks. because I hate to have to start billing people and dealing with accounts receivables, but such is the nature of business…
The Deposit
This also covers the issue of getting a deposit. If you’re not currently getting deposits for your work before you start, there’s only one reason….because you didn’t ask for one! I promise you, that most clients are more than willing to pay you a deposit. As a freelancer, you are a contract worker, just like a contractor that someone would hire to remodel their kitchen. Do those people work without a deposit? NO! The fact of the matter is, people expect to pay a deposit, but they’re not going to tell YOU that… if you don’t say anything they won’t either…. So start asking for a deposit before you accept jobs…
How much should I charge for a deposit?
How much you charge is really up to you. I routinely charge between 20-40%… usually the larger the job the lower the percentage. I try to get at least $100 in deposit, but I’ve gotten deposits upwards of $400. It just depends on the job. A good rule of thumb is to divide the total amount of the contract by the total time of the job and charge around one week’s worth(or a quarter of the total time, if it’s a short contract).
What if they don’t pay?
If a client doesn’t pay you right away, most times it’s because they are taking the time to check out your work, because they figure once you get paid you’re gone. There’s nothing wrong with that. What you have to look out for is if they are taking an exorbitantly long time and you haven’t heard from them. Whatever service you are using should have measures in place for you to request payment and take action against non-paying clients(I use elance.com). But, I find that generally a nice message explaining that you feel that the time to release payment has arrived and why you feel that way, is sufficient. Not an accusing message, but just letting them know that the job is complete. sometimes people really do just get busy and forget.
As an example, I had a client recently who we started work on a tuesday and he asked me to rush the job because it was “urgent” so I told him I can have it done by friday if it’s that urgent… I did and upon completion, he tells me that he will check it out on saturday and then pay me. normally that would be fine, but the fact that we were rushing the job, made me feel a little taken. I sent him a message pretty much explaining to him that given that we rushed the job at his request I had proceeded with the understanding that we would be done before the weekend and urging him to get it done on friday. He did and I got paid on friday. And he’s approached me to do more work… So, don’t be afraid to let people know what you require. remember, you are a business.. you can’t go in mcdonald’s and say “I’m not going to pay you until I taste the sandwich”… they have procedures that must be followed by the customer and there’s nothing wrong with you doing the same…
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
New Facebook Page
After reviewing my current promotional agenda, I found that I’m really slacking in the “selling myself” department, which is important, because the more popular I become the more I can charge and the less time I’ll have to spend working, which is the whole goal right..
So with that being said, I’ve created an official facebook page, finally! Please go like it, and read about my company….
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
I’m a one man show…
I read a few years back, in some tech journal, that the days of the lone programmer creating the next great piece of software are over. And at that time, I felt like it was true. I mean, with so much competition and technology growing at exponential levels, it was pretty much impossible to a lone programmer to even keep up, let alone create something awesome, just based on the fact there weren’t enough hours in the day.
Today though, things are somewhat different. There is a hardware revolution happening right now, with all the new gadgets(Iphones, Ipads, Windows phones, etc…). And that’s leaving a lag in the software area which means there’s time to do some great things. Also, there’s some really great programming languages established right now that aren’t going anywhere anytime soon, php being my preferred language.
That being the case, I’m finding myself in the midst of some great projects that, in the past, were the domain of two or more persons, if not a small company. Projects ranging from Major database driven real estate sites to my current project, which is a cross between blogger and facebook.
Whenever I take on these monster projects, it always seems a little scary, like I’ll never be able to get all of it done. But, after working on small chunks for the first week or so, I find that the rest of it comes very easily.
The lesson here, is to never be afraid to take a job simply because it seems like a lot of work, or like the kind of work that a whole company might do… Charge what the job is worth and break it down into smaller parts that you know you can do, then tackle them one at a time. Before you know it, you’ll be 80% done and looking forward to a huge payday(of course you got a deposit already, right???).
Peace!
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
Simple Pagination in PHP
One issue that I always get questions about in php is pagination, which is that situation where you have too many search results to fit on one page and need to break it up. I’m going to introduce a couple of new terms here:
- Ceil() – Built in function that rounds a fraction up to the next logical whole number
- Limit – Used in the query to limit the number of records returned
- Offset – Used in the query to offset the records returned.
For this example were going to be using a pretty simple sql query:
$query="Select * From records";
Now, Assume that query returns 1000 records but you only want to show 10 per page. The first thing you need to do is limit the number of records returned to 10. I’ll be using an external variable to limit my query(see Building Dynamic Queries), named $limit.
$limit=10;
$query="Select * From records Limit $limit";
With that done, our query is now only returning 10 records at a time. And our page doesn’t look like a phonebook anymore. But what about getting to the other 990 records?? For that we’re going to build a really simple “next” link. The link will increment based on what page we’re currently on. ie – if we’re on page 1 then the link will link to page 2 by simple setting a variable,$page, to the value “2″. After that, we have to set the offset variable which will tell us where to start counting from, in the search results.
Here’s the sample code:
//set the page to 1 as default
$page=1;
//set the limit
$limit=10;
//if no page is set then offset is set to 0, which means we start counting from 0.
if (isset($_GET['page'])){$page=$_GET['page'];}
if($page==1){$offset=0;}else{$offset=($page*10)-10;}//this is some math that figures the offset based on page number.
//create the next link
echo "<a href=\"searchpage.php?page=$page\">Next Page</a>";
$query="Select * From records Limit $limit offset $offset";
The math:
You’ll notice there’s some math being done on the offset variable. Bascially this is what’s happening. If we’re on page two, then that means we need to start at record number 10(11 really), since we’re showing ten per page. So to get an offest of 10 we multiply the page number by 10 and then subtract 10. So if we’re on page 3, we need to start on record 20, right? that means that $page*10-10 is equal to [(3*10)-10] =20…. and you’ll see that logic works with every page number. If you don’t get the math, don’t worry about it, just use it(lol), and you’ll figure it out as you start playing around with it.
I didn’t get to the ceil() function, but I’ll touch on it in the next installment.
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs
Content management systems are not for programmers
This post comes on the heels of a very long, fruitless(read unpaid), bout with Drupal. I was hired to make some changes to a current website, created with Drupal. I figured, I know Drupal so it should be no problem, right? Wrong! The way the site was setup was no conducive to a drupal setup. There was a lot of custom script, and in fact, there was so much custom code that the site didn’t even qualify as a Drupal site… The drupal content table was empty, and yet there was a full site operating, complete with database integration…
Now, correct me if I’m wrong, but isn’t the purpose of a Content Management System(like Drupal) to make it so that you can umm… Manage the content??? That’s not a dig at the author of the website at all. They did what they could with a drupal install… And thinking back, I can’t remember the last time I worked with an existing CMS and didn’t have to heavily mod (and break) it to get it to do what I want.
The bottom line is that Content Management Systems are not designed for programmers for one reason:
They’re too simple!
The major issue here is that with simplicity comes handcuffs. With all modern day CMS’ you are limited to the scope of the what the designer thought you might want to do, which is fine for the average person. But for a programmer, it’s just frustrating. You spend more time reverse-engineering the system than it would take to just write the code. Some things programmers have come up with are widgets & plugins, that expand the functionality of the current systems. But even that is limiting, and if the plugin doesn’t exist you have to write the plugin before you can use your code. In simplifying the process, what the CMS developers have done is dumbed it down to the point that they’ve crippled the ability to create great content.
It’s the same reason I hate Microsoft Windows™. Especially the newest versions. It’s become so “simple” that you really have no control over the system. Gone are the days of opening up a dos prompt(command line) and editing system settings…
“It’s not made for programmers”
I can already hear that argument being made. And true, they are not designed for programmers. But, as a freelancer, I’m constantly asked to design a site on these systems for the end user to manage(though inevitably, i end up managing it). Also, CMS’ are generally designed for pretty simple content. True, they can handle flash and whatnot with plugins, but they limit precise positioning, database accessibility, and general “programming” duties. And none of them support php, natively.
The Solution
The solution, as I see it, is to create a programmer friendly CMS that falls somewhere between Joomla and WordPress. Currently, most programmers default to wordpress. It’s extremely simple, with great support and a lot of plugins, and it allows for rapid prototyping(extremely important). But wordpress is designed to manage blogs, and using it as a CMS was an afterthought.
That being the case, I’m currently developing a CMS for rapid prototyping that will help to balance the simplicity with the restictions found in current systems. I’ve been developing it for my own use for about a month now, and after this recent bout with Drupal, I’m thinking I might release it into the public domain… More details soon
Christopher L. VaughanOwner/Operator
Vaughan Freelance Svcs


