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

CRELoaded Remove Google Ads -
ICECat Integration with osCommerce, Magento etc
Magento UK
PHP Cached Download Function

Most Popular Posts

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

Archive for the 'programming' Category

MySQL Copy Table from One Database to Another

Monday, March 3rd, 2008

Sometime in MySQL you want to copy an entire table from one database to a separate database. One example of when you would want to do this is if you are making a backup of a table before you apply some kind of processing to that table. There is nothing worse than ruining a database table and losing valuable information. To make an instant backup is so easy that there really is no excuse not to make backups at important or risky stages.

Here is how to do it:

PLAIN TEXT
MySQL:
  1. DROP TABLE IF EXISTS `backup_db.backup_table`;
  2. CREATE TABLE `backup_db.backup_table` SELECT * FROM `live_db.live_table`;

This will delete your existing backup table completely, then will remake it copying all structural information and content from the live_table in the live_db.

Related Blogs
http://www.phpclasses.org/browse/package/4017.html
http://www.sematopia.com/?p=61
http://www.yinfor.com/blog/archives/2008/02/mysql_backup_and_recovery_meth.html

Posted in mysql, programming, web development | 2 Comments »

Developing Web Applications in Windows

Tuesday, February 26th, 2008

My favourite platform for web development has to be Ubuntu Linux. As a desktop system to work on (rather than play) I think it is unsurpassed. However there are some times that you really need to use windows. For example my laptop seems to refuse to install Ubuntu which means that I am forced to stick with windows XP for the time being. However windows can be a perfectly adequate web development environment.

One of the trickiest aspects of web development on windows used to be setting up the Apache, MySQL and PHP stack. However this is no longer the case thanks to the wonderful little package called XAMPP. This is short for XP, Apache, MySQL, PHP and Perl.

Xampp allows you to run a webserver on your local computer. This allows for superfast editing and checking of your web application. Anyone who has repeatededly edited and FTP'ed a file to a webserver will know that it can quickly become a pain and definitely slows down your performance as a programmer.

By editing the file locally and simply refreshing your web browser you can quickly see how your web design is looking or ensure that your PHP is not throwing any errors etc.

Furthermore, using XAMPP allows you to start and stop the entire web server stack easily from one simple control panel.

Download XAMPP from hereĀ 

Posted in Windows, programming, web design, web development | No Comments »

osCommerce Essential Modifications

Thursday, February 21st, 2008

osCommerce is an awesome ecommerce package. It has many critics and this is mainly due to the fact that unlike many modern open source packages it is not really ready to run "out of the box". That is a drawback, however it is not really so much of a drawback when you take into account that anyone that would want to establish an ecommerce presence is going to be very keen to modify the package to make the site look and feel unique.

This is where osCommerce really shines as it is very easy to modify and there is a huge user base with literally thousands of plugin modifications or "contributions" in osCommerce speak which can help you to make your store work in exactly the way you want.

There are some things though that are highly recommened for every osCommerce store though:

1. Search Engine Optimisation

As standard, osCommerce really is not very search engine friendly. Search engine friendliness is the first step towards search engine optimisation. This of course means that there are a fair few things you need to do to your store to make it truly search engine optimised. However, they are worth the hassle (especially if you get us to do it for you) and once you have some SEO modifications implemented, you will be able to start to get indexed and gaining visitors from the search engines without having to pay per click.

2. Speed

There are a few key things that every store should really do to speed up osCommerce. If however you expect your store to have a lot of visitors and/or display a lot of products and categories then you will really benefit from giving the front end of the site a bit of an overhaul in certain areas. The speed improvements possible are really quite dramatic and can make the difference between your visitors sailing through the site straight to the page or product they want or them getting bogged down, bored and finally leaving before they even get where they want to be.

3. Security

osCommerce is pretty secure out of the box. The admin side obviously needs some password protection and can be made more secure if it is felt neccessary. An easy modification is to simply rename the admin folder into something that only you know.

4. User Friendly

The osCommerce ecommerce system is fairly user friendly from the outset. One area that many people prefer to modify though is the checkout procedure which can be a bit long winded for some.

5. Easy Administration

Admin side there is a whole host of things that you can do to make your and your employees' lives easier. For example adding products one by one using the admin tool can be a bit tedious and slow. Easypopulate is an awesome addition to any osCommerce store allowing easy population and editing of the product catalogue using your favourite spreadsheet program. We like Open Office for this task.

Part of the joy of running your own web site is that you are free to edit, change, personalise and improve it to your hearts content. Some things you will add because they make a real difference to your bottom line and some things you will add just because you think its a good idea or will be cool. The great thing with osCommerce is that you can edit it and make it work the way you want.

If you are not confident with PHP or the change you want to make is a bit more complex than you can handle, then we are more than happy to get in there and give you a hand!

Posted in oscommerce, php, programming, search engine optimisation, web design, web development | No Comments »

Who Needs Photoshop? PHP GD Images and Your Online Store

Monday, February 18th, 2008

Many web masters will be familiar with Photoshop by Adobe. This highly featured photo editing and graphics application is incredibly powerful, but also incredibly expensive. If you find that the main thing you do with photoshop is basic product image cropping, resizing, trimming, rotating and watermarking then there is a better way!

If your server uses PHP and has GD functionality enabled, you can use the power of the GD library to automatically do all of these things for you. Furthermore the GD library is faster than using photoshop and as the process actually runs on your server, you do not have to worry about uploading files. Your employees can directly manipulate product photos from your web store administration screens.

Chances are the main thing you will need to do is to take one hi res source image and create one or more resized versions of it to be displayed as thumbnails or product info page images. Your Hi Res images can then be displayed as a pop up or lightbox.

There are many PHP GD thumbnail classes etc out there and you will easily find one by searching the major search engines.

Here are the basic concepts though:

1. Grab an image into memory from an external jpeg file
Before we can do anything we have to get an image into the memory. This then gives us something to work with.

PLAIN TEXT
PHP:
  1. //grab image into memory,  $img = full url to jpeg image
  2. if(!$jpeg = imagecreatefromjpeg($img)){
  3. echo '
  4. <h2 style="color: red">Failed to Grab Image ' . $img . '</h2>
  5. ';
  6. exit;
  7. }

2. Manipulate Image however you want
There are all kinds of things you can do with the image you have loaded using the GD library.

3. Display the Image or Save to Disk
Once you have manipulated the image and have it looking the way you want, you can either serve it up or save it to the disk. Of course you can also do both if you prefer.

PLAIN TEXT
PHP:
  1. //save image
  2. $save_path = 'Your Save Path';
  3. imagejpeg($jpeg,$save_path);
  4.  
  5. //display image
  6. header ("Content-Type: image/jpeg");
  7. imagejpeg($jpeg);
  8.  
  9. //destroy image to free memory
  10. imagedestroy($jpeg);

Related Resources
http://uk3.php.net/gd
http://www.phpclasses.org/browse/package/1365.html
http://www.phpit.net/article/image-manipulation-php-gd-part1/

Posted in gd, php, programming | No Comments »

Building Spiders: Grab Data, Post Forms and Interact with Web Sites Automatically

Thursday, February 14th, 2008

One of the most useful and powerful things you can do with PHP is to create a programme which will simulate a web browser and can grab data, post data to forms and generally interact with other web sites - automatically.

For PHP to be able to work like this it must have the CURL library installed and active. It is the CURL library which actually handles all of the interaction and PHP is my scripting language of choice for interacting with CURL.

A simple CURL function is like this:

PLAIN TEXT
PHP:
  1. function curl($url){
  2.  
  3. $timeout = '300'; //how long before CURL gives up on this page
  4. $go = curl_init();
  5. curl_setopt ($go, CURLOPT_URL, $url);
  6. curl_setopt ($go, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt ($go, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_setopt ($go, CURLOPT_TIMEOUT, $timeout);
  9. $spage = curl_exec($go);
  10. curl_close($go);
  11. return $page;
  12.  
  13. }

This function when called and echoed will output the entire html of the $url specified.

For grabbing data from this page to be inserted into a database (for example when spidering a suppliers web site for product information to be inserted into your site) we then use regular expressions to find what we are looking for and then insert that into the database.

so for example if we wanted to grab the product title and we knew that this was wrapped in a h1 tag with the class "product title" we could use this regexp to grab this:

PLAIN TEXT
PHP:
  1. $page = curl($url);
  2.  
  3. $pattern = '%
  4. <h1 class="product_title">(.+?)</h1>
  5. %i';
  6.  
  7. preg_match($pattern,$page,$matches);
  8.  
  9. print_r($matches); //we can see the entire array of matches and choose which we want to insert into the database

We can also Post data to web sites using curl. This allows us to do all kinds of things including grabbing data that is displayed on the submission of post forms. Here is an example Curl Post Function:

PLAIN TEXT
PHP:
  1. function curl_post($url,$post_data){
  2.  
  3. $timeout = '300'; //how long before CURL gives up on this page
  4. $go = curl_init();
  5. curl_setopt ($go, CURLOPT_URL, $url);
  6. curl_setopt ($go, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt ($go, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_setopt ($go, CURLOPT_TIMEOUT, $timeout);
  9. //now for the post section
  10. curl_setopt($go, CURLOPT_POST, true);
  11.  
  12. curl_setopt($go, CURLOPT_POSTFIELDS, $post);
  13. $spage = curl_exec($go);
  14. curl_close($go);
  15. return $page;
  16. }

It can be tricky to figure out exactly what data should be in the post string. To help you out though is this incredibly handy addon for firefox: Live Http Headers.

This addon lets you see exactly what is going on between your browser and the web site you are visiting. This can quickly and easily give you the information you need to replicate the same behaviour with your CURL script.

Edmonds Commerce specialise in working with PHP and CURL. If you have any spidering, screen scraping or other application that requires PHP to actively interact with other web sites - get in touch today to see how we can help you benefit from this incredibly powerful technique.

Related Resources

http://www.phpfour.com/blog/2008/01/20/php-http-class/

http://www.phpclasses.org/browse/package/1988.html

http://www.phpit.net/article/using-curl-php/

http://skeymedia.com/intro-to-curl-with-php/

Posted in curl, firefox, php, programming, spidering | No Comments »

  • RSS Feed
  • Categories

    • apache
    • barcode
    • creloaded
    • curl
    • customer services
    • debugging
    • ecommerce
    • 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
    • spidering
    • ubuntu
    • web design
    • web development
    • Windows
    • xampp
    • zip
  • Archives

    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
  • Tags

    addons advanced adverts blackhat blocking css curl 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 security seo serp speed spider spidering tuning user friendly vista web web design web developer
  • Random Posts

    • Regular Expression Test Tool
    • Plesk Web Fusion PHP Limits
    • PHP: Recursive Create Path (if not exists)
    • MySQL Find and Replace
    • Magento UK
    • Handy Easy Javascript
    • Debugging PHP Scripts
    • Chemos SEO URLS for osCommerce
    • Saving a File or Webpage using PHP
    • Favourite Firefox Extensions

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

Freelance PHP Web Design UK Commercial Web Design