Recently Posted

Archive for the ‘PHP’ Category

I found a great site that lists some very useful CSS, HTML and PHP code snippets. They can be found below:

Part 1
Part 2
Part 3
Part 4

Well here is something I was sure was impossible until the other day. I managed to use a remotely hosted include file in one of my pages. The reason I did this was because all of the coding needed to connect to a database on another site. I think the only reason it worked though is because although the code was on another site, it is on the same server. Still, it worked for me!

Sadly, this just isn’t possible. You would think you would be able to do the following:

[source: php]

include (”filename.php?variable=123″);
[/source]
But you just can’t. There is an alternative though. You can set the variable just before you include the file, for example:

[source: php]

$variable=123;
include (”filename.php”);
[/source]

I think the best tool I use often in developing a website is the internet itself. If there is anything I don’t know or am stuck with, I Google it. As you probably know Google is now actually a verb in English dictionaries. This is due to the fact that so many people use Google to research and seek out information due to its superiority over other search engines.

Over the last few years I have come across many tools and utilities that have helped me complete various tasks and I have decided to list them here in the hope that the will be of help to some else. They are not listed in any particular order as they are all great.

Edit PlusEdit Plus
Download

Edit Plus is a great text editor that supports probably every known programming and database language there is. It has great colour highlighting, ftp, customisable scripts and extensions and much more. Its a 30 day free trial, but in the past I have used it for much longer than 30days meaning, I guess that purchase is voluntary. No doubt you will find it so useful you might consider paying the shareware fee.

Read the rest of this entry »

I thought for this blog item I would write about something fairly simple, that should help a lot of people. PHP has a very useful built in function simply called date(). Guess what it does? That’s right it returns the current date, but it can be used with other functions to do much more.

Here is a very simple example of its usage:

echo date(”F j, Y, g:i a”);

This will print out the today’s date in this format:

Month, Day, Year, Hour, Minutes and AM or PM

If you simply wanted to show the time and not the full date you would use:

echo date(”g:i a”);

For a more detail on using the PHP date() function visit www.php.net/date

Hi and Welcome

Apparently in 2007 blogs are going to peak, meaning after that they will decline. As a web designer I have decided I don’t want to miss out and have decided to build up a blogging empire! I have 4 main objectives in writing these blogs as listed below:

1. As another creative outlet and a means to share ideas with other people

2. To generate traffic to help boost all of the other sites I build

3. To possibly generate some revenue through google adsense and other advertising

As this is the first post, probably no one will be reading this except myself and possibly few search engines, but over the course of the next couple of months I am going to employ various techniques and strategies to boost the amount of traffic. I will be listing these techniques and ideas here in the hope that someone else will find them useful.

In this post I want to talk about something I only found out about the other day, dynamic sub domains. As you probably know, this site itself is hosted on a sub domain, http://blog.voodoochilli.com. The actual domain www.voodoochilli.com is my company website and the blog part is the sub domain. I know from experience that sub domains can rate very highly search engine wise, and they are a very cheap alternative to buying a fully qualified domain as there are no extra registration costs (although your hosting company may charge you a set up for a sub domain)

Dynamic sub domains means that you can generate these on the fly using a .htaccess file. First though you have to make sure you have wildcard dns turned on for your domain. You can test this by typing anything.yourdomainname.com and if you don’t get a 404 page the chances are this is already set up. Once you have this in place you need to look into .htaccess.

Heres an example of a .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourwebsite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourwebsite.com
RewriteRule ^(.*)$ /path_to_your_site/httpdocs/work_out.php?url=%1

Remember: This file must be called .htaccess exactly, with no file extension; when you upload it to your server it will probably be invisible so keep a backup!

The .htaccess file will then send the variable $url with the sub domain, so for example if you type in:

http://test.yourwebsite.com

This will translate to (but not be visible as)

http://www.yourwebsite.com/work_out.php?url=test

On one of my sites the work out page checks the MYSQL database for the username and simply brings up the profile for that person. As far as a visitor is concerned we are actually at http://test.yourwebsite.com. There are other ways of doing this, but after looking it up this seems the easiest.