All posts in PHP

Advanced image resizing in PHP

advanced image resize in PHPPHP has some nice features for resizing and modification of images. In this post we’ll build a script that can take local or remote images, resize the images based on a bounding box, and optimize the files, so the file size gets as small as possible.

The script saves the resized and optimized images as jpg files.

This script can be very useful if you wants to automate downloading and optimization of external images, or has a big collection of images that needs to be resized.

Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Finally – statistics for your mobile site in Google Analytics

Google analytics finally ready for mobile xhtmlTracking traffic on mobile site has so far been quite difficult. The majority of the web analytics programs are based on JavaScript tracking, which is problematic with mobile sites, since many mobile devices still have bad support of JavaScript.

The good news is that Google Analytics now has been upgraded with additional tracking features, that allows tracking of mobile sites, even for mobile phones without JavaScript support. In this post you’ll learn how to add Google Analytics tracking to your mobile site.

Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

The perfect 404 page

error 404 iconA error 404 page is displayed in the cases where another site is linking to a URL on your site that isn’t available.

There can be different reasons why the URL isn’t valid, maybe you redesigned/restructured  your site to a new URL structure, maybe somebody just made a typo in a link or in the browsers address bar, or maybe some of your content has been removed.

There are different philosophies about 404 pages. Some people just want to redirect the users to the sites front page, however if the user expects to see a very specific page on your site, being redirected to the front page isn’t a very good user experience.

In this post we’ll build a 404 page in PHP that tries to guide the user as close as possible to the most relevant content on your site.
Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Protect your PHP script from SQL injections in 5 min

Prevent your site from SQL InjectionWith SQL injection, people with bad intentions can delete or change content in your MySQL database.

The good news is that there is a simple solution to prevent SQL injections, so there is no excuses not implementing this technique to your PHP scripts asap.

In this post you’ll learn about SQL injections, and how they can be prevented in your PHP scripts.
Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Geocoding with Google maps and PHP

Geocode addresses to lat/long with Google Geocode APIThere are several high quality map services available on the web. However if you want to use some of these services for your website, you’ll need lat/long coordinates on the geographical data that you wish to display.

I you only have a few addresses to display, you can look the coordinates up on services like Google Maps or Bing maps, but if you have to get lat/long coordinates for several addresses, you need a geocoder to convert the addresses to lat/long coordinates.

In this post you’ll learn to build a php script that can geocode addresses with Google Maps API

See example here

Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

SEO friendly url’s

The URL structure of your site is very important for both users and search engines. A short URL, that gives some indication of what can be found on the page is more trustful, than a very long URL with a lot of parameters that can be difficult to understand.

From a SEO perspective, if important keywords are included in the url, this can increase the overall seo credibility of the page.

In this post you’ll learn to build 2 types of nice URL’s for dynamic sites: .htaccess url rewriting and URL parsing techniques.

Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Output MySQL data in columns

If you’re going to display a huge number of data from MySQL, a one column list might not be the optimal solution. In some cases,  a 2 or 3 column list makes it easier for the user to navigate in the result, and makes the page shorter.

In this guide you will learn how to make a simple php script that can output data into nicely formatted columns.

Read more…

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS