MySQL via SSH for PHP

I was moving a site from one server to another which has a lot of database transactions, and I did not want to lose any. So at 2am I started the move, at this time the traffic is fairly quiet. Then I realised that neither hosts allowed remote access to MySQL without their super admin’s help. I didn’t like the idea of trying to sync the databases up after the fact so I created an SSH tunnel to the new DB. This meant I could have the old server’s PHP talking to the new server’s MySQL until the DNS propagation was complete.

To do so:

1. I exported a MySQL dump from the old DB server and upload it to the new server

2. In terminal (PuTtY for Windows fans) I SSH into the old server and from there created a port (3377) on the old server which pointed to the new server

[cc lang=”bash”]ssh -L 3377:[/cc]

3. I wanted to see if it worked so I run MySQL in a new terminal window (the existing terminal window needs to remain open, as the switch over of A-Record will not take long I am not worried)

[cc lang=”bash”]mysql -u dbuser -p -h -P 3377[/cc]

4. MySQL on the old server was able to connect to the MySQL instance on the new server

5. Finally I needed PHP on the old server to connect to the MySQL on the new server while the propagation period is taking place

[cc lang=”PHP”]$db = mysqli_connect(‘’, ‘dbuser’, ‘password’, ‘the_db’, 3377);[/cc]

And that is it!

Outputing PHP to Excel

A few people have recently asked me about outputting data to Excel. This is a very simple thing to do from PHP with two lines of code.

[cc lang=”PHP”]header(“Content-type: application/”);
header(“Content-Disposition: attachment; filename=webbased.xls”);[/cc]
Continue reading

Challenges to create an ecommerce solution

A new doll in my collection

When designing an ecommerce solution there is many challenges which the developer needs to take into consideration to save time and frustration for both them and the client. Good planning and asking the right questions up-front will help in over coming the challenges. Below is a list of some of the challenges faced in creating an ecommerce solution and some basic questions that should be asked to minimise the challenges.

Ecommerce is focused on workflow compared to website design which is focused on content and layout. When designing an ecommerce solution the most important part is to understand the workflow. This involves working through each of the stages of the process the solution is meant to solve. While there may be existing processes, the online tool should be about refining those processes instead of just creating an online version of the offline solution. The first questions that should be asked are:
Photo by Joel Mark Witt
Continue reading – Domain Name Generator

I must say my favourite tool I ever built is – Domain Name Generator and – Domain Name Generator. It is simply the best at finding unique and awesome domains.

Today I found and the other day The tool is super easy to use and logical. All of the results are in a single window.

After using this domain generator you will never use another one again.
Continue reading