Edmonds Commerce Logo
  • home
    • blog
  • ecommerce
    • product catalogue
    • order processing
    • customer services
    • stock control
    • human resources
    • management information
  • development
    • oscommerce
    • php
    • mysql
    • open source
    • performance tuning
  • design
  • marketing
  • contact us
    • pricing

Edmonds Commerce Blog

Freelance PHP Ecommerce and SEO Developer in the UK

Latest Posts

Zend_Dojo Dijits and Numeric ID’s
Happy New Year from Edmonds Commerce
Easy Security for PHP Scripts
Secure and Insecure Contents in HTTPS

Most Popular Posts

PHP Email Attachment Function Freelance osCommerce UK Ultimate osCommerce Checkout - Fast and Friendly PHP : Dead Easy Excel Export

Archive for May, 2008

PHP 301 Redirect Function with Headers Check and Javascript Fallback

Thursday, May 22nd, 2008

If you are changing your URL structure, for example when moving to a search engine friendly URLs system, you need to be able to let Google and all the other search engines that the page has moved to the new URL. You really don't want to display the same content on two URLs

So to achieve this we can do what is called a 301 redirect. This is a special redirect message which basically says "has permanently moved to". By doing this, all of the search engine power, rank or whatever you want to call it will be directly transferred to the new URL.

However

Sometimes your script might spit out the headers earlier than you expect. If this happens then your site will fail completely to load with a fatal error along the lines of

warning: Cannot modify header information - headers already sent by (output started at ....

We really don't want this to happen, so what we can do is wrap the redirection in a headers_sent check and then fall back to a javascript redirect if headers have been sent for some reason. This is belt and braces logic.

Note script tags need spaces removing

PLAIN TEXT
PHP:
  1. function requrl_check($correct_url, $delay=3){
  2.     $request_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  3.     if($request_url != $correct_url){
  4.         if(!headers_sent()){ //going to assume that headers are not sent
  5.         header("HTTP/1.1 301 Moved Permanently");
  6.           header('location: ' . $correct_url . '');
  7.           exit();
  8.        }else{
  9.           echo "<h3>The Page $request_url has Moved</h3>
  10.          <a href=$correct_url>$correct_url</a>";
  11.           echo '<h3>Now Refreshing in ' . $delay . ' Seconds</h3>Refreshing to:<br>' . $correct_url . '<s c r i p t type="text/JavaScript"><!--
  12.         setTimeout("location.href = \'' . $correct_url . '\';",' . ($delay * 1000) . ');
  13.         --> </s c r i p t>';
  14.             exit();
  15.         }
  16.     }
  17. }

tidy :-)

Further Reading:
www.stuntdubl.com
www.intertwingly.ne
webgasm.actiononline.biz
www.techcounter.com
www.chiropractichomepage.com
123howtoguide.com
searchblog.tamar.com

Posted in php, search engine optimisation | No Comments »

osCommerce Contribution Released: Server Migration Synchronisation

Wednesday, May 21st, 2008

Server Migration Orders / Customers Synchronisation

This contribution is for people who have moved or are moving server. When this happens you have to update your DNS records to point your domain name at your new server. However it takes a little bit of time for this change to fully propogate through the internet meaning that for a period you will take orders at both servers.

Once your DNS has fully propogated you can use this system to generate a mysql dump of all of the orders/customers on your old site that need to be moved across to the new server.

Posted in oscommerce | No Comments »

PHP Generated SQL

Wednesday, May 21st, 2008

If you find yourself laboriously building SQL queries by typing each field = 'value' statement... think again.

Imagine this:

PLAIN TEXT
PHP:
  1. $sql_query = mysql_query("select * from table");
  2.  
  3. $insert_elsewhere_sql = "INSERT INTO other_table SET ";
  4.  
  5. while($s = mysql_fetch_assoc($sql_query)){
  6.     foreach($s as $k=>$v){
  7.     $insert_elsewhere_sql .= "$k = '$v', ";
  8. }
  9.  
  10. $insert_elsewhere_sql = substr($insert_elsewhere_sql, 0, -2);

This will generate a valid SQL insert statement with all of your field, value pairs set up.

Time saver or what?

Posted in mysql, php | No Comments »

Purashop : SEO Services

Wednesday, May 14th, 2008

I am right in the middle of a big SEO overhaul for purashop who have been good clients of mine for a while now.

My initial project for them was a fast checkout system. Getting rid of the standard osCommerce checkout procedure and rolling it all up into a single page which is loads faster, easier to use and much more customer friendly.

They have recently asked me to help them out with their search engine optimisation. The first thing I have done is install my bespoke SEO URLs system. This includes product, category and manufacturer SEO URLs. It even includes SEO page urls, no .html?page= for these guys, it's a full static looking URLs system and runs with even less server load than the original oscommerce.

This is a major contrast with the Edmonds Commerce approach to SEO URLs compared with other systems out there. I have seen people who are using systems which dynamically preg_replace every single URL after it has already been generated, adding a huge amount of server load.

The extra icing on the cake though is the SEO URLs search system combined with a search logging system and a popular searches page. This page is excellent as it is not only a nice resource for customers, but is incredibly search engine friendly. As the content is dictated by the searches performed on the site, the page constantly keeps itself up to date with the latest trends and will constantly optimise their site for the most relevant and active topics of the moment.

I am continuing to tweak and improve their SEO package and have high hopes for a marked improvement in traffic in the not too distant future.

Posted in php | No Comments »

Flash and PHP Charts and Graphs

Wednesday, May 14th, 2008

It is entirely possible and easy enough to create all kinds of charts and graphs using only PHP along with the GD library.

These days PHP is generally compiled with the GD library enabled so it is highly likely that you already have access to it. It is a powerful system, unfortunately often only used for creating thumbnail images.

For building management information systems with real time generated graphs there are some excellent classes available which will help you display information in a graphical and therefore easier to understand manner.

Checkout these great free graph classes:

Class: Google Graph
Class: Bar Graph generator
Class: Graph Drawing Class 2

However, sometime the graphics produced by GD simply are not flash enough for your application.

When you want something really flashy on your web site then you really can't go wrong using flash.

There are a few flash graph packages you can purchase online for not too much cash. However if you prefer to keep it all open source then I highly recommend checking out this open source flash graph class.

Open Flash Chart project

Further Reading:

noteplog.com
bivald.com
blogs.sun.com
www.webappers.com
blogulate.com
www.linewbie.com
hotware.wordpress.com
wordpress.designpraxis.at
www.stat.columbia.edu

Posted in flash, gd, graphs, php | 3 Comments »

osCommerce Output Queries Debug : Store Speed Optimisation

Wednesday, May 7th, 2008

A common requirement for oscommerce store owners is to try to get pages loading faster.

Part of the problem is that each oscommerce install is different, with a mixture of contributions and bespoke customisations all making their own database queries and causing their own problems. The first part of the solution is to actually be able to see what is going on. For this you need to install the Output Queries Debug contribution for osCommerce.

After that, it is really down to looking through the debug information and tracking down the errant code or SQL and trying to tidy it up.

This is something we specialise in, if you need any help getting your oscommerce store up to speed, simply get in touch.

Posted in oscommerce | No Comments »

osCommerce Password Reset Using phpMyAdmin

Tuesday, May 6th, 2008

Sometimes you need to get in there and reset the password for oscommerce using phpMyAdmin.

In these instances, you do not just paste in a new password but you have to properly encode it first.

Here is a really handy tool to create a password hash for you, ready to be pasted into phpMyAdmin

for the admin side, you will need to edit the admin table and paste this into the password field for the account you need to set the password for.

Check out this easy oscommerce password generator

Posted in oscommerce | 1 Comment »

Faster File Browsing with Tabs for Ubuntu

Tuesday, May 6th, 2008

If you are constantly dealing with complex file structures and accessing various folders, the traditional "window for each folder" approach can quickly leave you with a cluttered work space and you may find your self taking time to find the right window.

For Ubuntu users, the PCMan file browser comes to the rescue with not only noticably faster file browsing but also firefox style tab support.

This is a real productivity enhancer and is an absolute pleasure to use.

You can download the easily installed deb package from here

http://www.getdeb.net/app/PCMan+File+Manager

Posted in ubuntu | No Comments »

HP Printer on Ubuntu

Thursday, May 1st, 2008

You might struggle getting your Hewlett Packard printer to work with Ubuntu, I know I did.

However Ubuntu now comes with something called HPLIP installed. You can find it and install it using synaptic package manager

To get your printer to actually work simply run sudo hp-setup from the command line

http://hplip.sourceforge.net/install/step4/index.html

Posted in ubuntu | 1 Comment »

  • RSS Feed
  • Categories

    • apache
    • barcode
    • business
    • creloaded
    • curl
    • customer services
    • debugging
    • ecommerce
    • edmondscommerce
    • email
    • excel
    • firefox
    • flash
    • gd
    • graphs
    • hosting
    • icecat
    • internet news
    • javascript
    • link building
    • linux
    • magento
    • management
    • mod_rewrite
    • mysql
    • oscommerce
    • php
    • plesk
    • product catalogue
    • product feed
    • programming
    • regular expressions
    • scraping
    • search engine optimisation
    • security
    • seo
    • spidering
    • ubuntu
    • Uncategorized
    • vps
    • web design
    • web development
    • Windows
    • xampp
    • zip
  • Archives

    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
  • Tags

    addons advanced adverts blackhat blocking css development directories find firefox google hosts file html javascript keywords links msn mysql myths operators oscommerce paid links paid placement performance php ppc reciprocal linking replace screen scraping search engine optimisation security seo serp speed spider spidering tuning user friendly vista web web design web developer
  • Random Posts

    • osCommerce Easypopulate File Creator Class
    • osCommerce UK
    • Happy Christmas from Edmonds Commerce
    • EAN13 Barcode Check Digit with PHP
    • PHP Email Attachment Function
    • MySQL Find and Replace
    • Is My Site Down For Everyone or Just Me?
    • Why VPS is Not for Everyone - Yet
    • PHP Save Images Using cURL
    • PHP: Recursive Create Path (if not exists)

Edmonds Commerce related questions? Send us a message or call us on 0844 357 0201.

Freelance PHP Web Design UK Commercial Web Design