Script Perfect

         Random snips of code and bugs

Archive for September, 2009

Detecting Bad Words PHP (Filter bad words)

Posted by Tim On September - 17 - 2009

Simple and easy, stop most of the nasty words from appearing on your website or blog with one simple function. This has stemmed from multiple users posting profanity on another one of our sites. After searching far and wide for an easy solution, alas we could not find one. This resulted in a few hours behind the keyboard plucking away with some trial and error, the end result is a lightweight function that works great.

The hardest part about developing a function that would detect profanity was accounting for the special characters being used as letters. Like the “#” being used for a “H” or a “$” for a “S”. The solution to detect the special characters was rather simple once we figured out a good method. Now, in it’s entirety, it will stop most profanity and if any gets through it is very easy to modify it for additional characters and words.

Read the rest of this entry »

Simple Tool Tips w/ Only CSS

Posted by Tim On September - 17 - 2009

Flashy unobtrusive boxes that give hints and tips to your visitors can be very helpful, informative, and improve your sign ups or sales. You can accomplish this nifty feat without any plugins or API’s weighing down your site. Of course with JQuery UI or Scriptaculous you could add some impressive eye candy and give your tool tips a more professional appeal.

Any time you require a user to click an information link or button you may be taking away from the user experience and even more possibly losing a repeat visitor. Using a tool tip is very easy and will give your visitor all of the information they need to complete a form or application without being diverted to another page or loading a pop up.
Read the rest of this entry »

Optimizing Your Website – Speed and Performance

Posted by Tim On September - 14 - 2009

website optimizationNothing like listening to the whirl of your hard drive as the progress bar in your browser slowly creeps forward.  There are so many pitfalls which designers and coders fail to see when designing a website. CMS users beware, you too could be a victim. I have seen many articles on increasing performance as well as lists which show the “Top 10″ items, they are all great but let’s be serious for a moment.

Misuse, abuse, overuse, and just plain ignorance results in slow loading sites, these are not all the same. Sure there is poor code out there, but it can run better and faster than a clean written site when many obstacles are overcome. As high speed internet takes over and bandwidth becomes second to file size we can not lose focus on what is slowing our sites down.
For those who don’t like to read, a top 10 list is at the bottom

Read the rest of this entry »

LessConf – Jacksonville FL

Posted by Tim On September - 12 - 2009

It is that time of year, the Less Conf is now registering with some perks! If you are one of the first 200 guests to register you have the option to eat lunch with one of the speakers! The guests this year include Gary Vaynerchuk of WineLibrary, Derek Sivers of CDBaby, Mike McDerment of FreshBooks, Kevin Hale of WuFoo, Des Traynor & Eoghan McCabe of Contrast i.e., David Hauser of Grasshopper, and a special guest which is still unannounced.

The conference will take place on the 17th of October in Jacksonville Florida, hosted at the Times-Union center. The conference will run from 8am to at least 8pm ending with a social gathering. The conference is designed to inform, enlighten, and educate all flavors of web developers, designers, entrepreneurs, and enthusiasts.

Visit LessConf to register!

Read the rest of this entry »

PHP and APC – Tutorial

Posted by Tim On September - 12 - 2009

APC is most widely known for allowing the end user to be able to track the progress of file transfers. APC, which stands for “Alternative PHP Cache” does much more than that. Complex and large scale websites can benefit from it’s ability to cache data and as well as its optimization of PHP code.

If you are looking for a tutorial on using APC for tracking file upload progress then visit my tutorial for File Upload Progress

APC does not have a large host of commands, this does not ease the complexity. We will take a look at a few simple functions and explain their use, in addition I will try to explain the practical reasons to use them. There are a few warnings to adhere to when trying utilize alternative PHP cache, these will also be discussed.

Read the rest of this entry »

Basic Auto Suggest with Ajax and PHP

Posted by Tim On September - 11 - 2009

ajax auto suggestYou see it in Yahoo, Google, Bing, and all over the web. As you type into a search feild a box appears before your eyes showing you suggestions based on what you are typing. This offers more than just ease of use for your visitors, it allows them to see other content related to their search that they may have been otherwise unaware of. There are many tutorials on this subject, many of which rely heavily on API’s or copyright protected files.

Developing an auto suggest form is rather simple, with the right methods you too can churn out a professional looking auto suggest form without the complicated mess that many others provide.  Visitors are likely to return to your site (provided the content is valid) to use features like this because so many other sites are slow in developing this type of technology.

The concept is simple, we run a JavaScript function every time a user presses a key in a search box, we use Ajax to send and receive data to a php search function and return the results to our page.

Read the rest of this entry »

HTML and CSS Templates, Best Free Resources

Posted by Tim On September - 10 - 2009

There comes a time when designing a new layout becomes more than a chore or time becomes your main constraint. When trying to develop a well formed website which is cross browser compliant and validates correctly you could spend days just coming up with a basic format. Thanks to many designers and developers you do not have to do all of the leg work yourself.

This list details some of the best resources I could find which offer free HTML and CSS templates for your website. They are in no particular order but all offer great quality layouts. Enjoy…

Read the rest of this entry »

JQuery UI vs. Scriptaculous

Posted by Tim On September - 10 - 2009

scriptaculous vs jquery uiDoll up your website with great effects and widgets by using JQuery UI or Script.aculo.us. It is becoming easier and easier these days to impliment all sorts of effects to your site with just a few lines of code.  One question many people have is which one of these interfaces reigns supreme over the other? The answer is not really that simple considering how many different flavors of designers, code monkeys, and developers there are today.

There has always been a huge argument over the file size when using any plugin… “In the left corner weighing in at 450.5KB is JQuery UI! In the right corner weighing in at 621KB is Scriptaculous!”. It does not seem like that big of a difference, I mean we are only talking about 17oKB difference between the two.  If we were to minimize both of these files and enable file compression on our servers I doubt you could even notice a difference on a good 56KB modem connection. So what are the benefits of using one over another?

Read the rest of this entry »

Ajax – A Squeeky Clean Website

Posted by Tim On September - 8 - 2009

Ajax, not the cleaner, the asynchronous JavaScript and XML, it is like viagra for your website. Pop in a little Ajax and your website is performing better and making your “visitors” happy. As with viagra you need to read the warning labels associated with Ajax.

Warning:

Ajax should be used in moderation. If your server maintains a full load for more than 4 hours as a result of using Ajax, you should consult a programmer immediately. Websites hosted on shared servers or those intending to move to a shared server should not use Ajax as this may cause complications during deployment.

Seriously though, over use of Ajax can cause a lot of load on your server if you are processing too many requests at the same time, often the requests that tax the server the most include database queries. Don’t get me wrong, I love Ajax and I think every site could put it to good use. This is why I am going to show you a few simple methods to implement it on your site to make your visitors time more enjoyable.

Read the rest of this entry »

PHP Database Class, The Right Way

Posted by Tim On September - 8 - 2009

How many times do your fingers type out the commands to run a query or fetch a row? If you are performing database tasks on the majority of your pages and you have not simplified the process then you need to keep reading. Developing a database class is not very difficult, in fact there are plenty of them out there which can set you on your way. Once you start using them you will most likely never go back.

A database class should be thorough, simple, and save you time. A single command to connect or disconnect as well as most of your common functions should be included. Do not re-invent the wheel if you have a large scale project, there are plenty of pre-build APIs which will handle much more than the examples given here. Below is a simple class which can get you up and running as well as examples of how to use it, let’s take a look:

Read the rest of this entry »

About Me

I am an independent web developer and webmaster of many sites. The main goal of Script Perfect is to provide answers to some of the hard to find questions when it comes to website design and coding.

Twitter