Chris Worfolk's Blog


Tis a new day

July 12th, 2004 | Life

Well who would have thought we could sustain interest for more than 24 hours? Ah well we have like an hour to spill out in ICT although we could do to get some law revision done. Anyway I have loads to post but have stuff to do now. Back later.

MySQL Timestamp

July 11th, 2004 | Life

Although officially I hate PHP, date() is pretty cool. The thing is that PHP uses a different timestamp format to the standard MySQL timestamp. Therefore the majority of timestamps stored in MySQL are actually stored as intergers. Or at least this is how phpBB do it. And that is how my latest site does it. But enough about quick plugs. What’s happening here?

Ah right, the thing about MySQL timestamp is that it updates to the current time everytime you update the column. Therefore when I had to make a change to the database to set a post to a different user, it updated the timestamp and moved the post to the top. Hmm, I posted this, maybe it evens it out or at least dislodges it from the top.

So, Malcolm in the Middle has just ended. Ok, here I am just trying to fill out space. Here’s a picture of Fonze again:

Remind you of anyone? Ayyyyy!

Resource album added to the site

July 11th, 2004 | Life

Hu, I lasted about 20 minutes. Not unexpected though really. I am still exploring the features of the site. On the left of the main page you can see a link called albums at the bottom, below the about link. This offers you the chance to see all our albums (well currently 1) and all the photos within these albums (again, 1). Enjoy!

I can add resources to posts apparently too, so if you go on the full link or permalink or whatever it’s called you should be able to see the full resource.

Or, if you are already on this page, you should be able to see it below ;):

Remind you of anyone? Ayyyyy!

Domain propogation time

July 11th, 2004 | Life

It would be cool if domains propogated faster – like instantly :). There is nothing worse than waiting around for them especially considering that they take anywhere from 12 to 48 hours. It will be good once Nerd Federation is officially back at the point we can start spreading the URL around again. Ah well, the time should come soon.

Time for today is publishing on and I really should start law revision but I am finally making visible process on my new site. It has an intergrated forum and I am moving towards finishing the posting and editing section then I only have the move topics section and the forum code guide and editor. Oh, its going to be a long night / a long week.

Remember exit() after location

July 11th, 2004 | Life

Well best get started with the random tips and information. One thing I am not happy about is this editor tells me I am using Verdana 8px, but when it comes out in the page it is Times New Roman! The blow is slightly cushioned for myself however as my browser, Beonex, uses Arial as the default font. A nice bit of scripting in the editor though means it is not compatable with Beonex – neither is vBulletin!

So before the moans side tracked me, I was getting into my story. Having started doing some stuff in PHP to make sure of forcetype and stats on subdomains (just wait until I get an ASP.net rewrite engin!) I found a few helpful bits of information that spent much time annoying me and ended up really simple. Most notably, not remember == for comparissions.

One other thing I noticed is that although you can redirect a user using the header location tag, it doesn’t actually stop the PHP script running. So the user may have been sent elsewhere but the thing they were not allowed to do and you had throught been stopped doing it because of the header location code you added, is still actually being done. It’s easy to fix though, all you need is:

Header ("Location: whateverpage.php");
Exit ();

Hmm, yet another over complication of PHP if you ask me. Still I’m kind of on a high right now as this editor is pretty cool. It has some quite extensive image adding features and plenty of HTML options. I give it my offical stamp of "neeto!" Well, I will probably be able to keep myself away for like an hour at tops, see you then.

Nerd Federation is back!

July 11th, 2004 | Life

After a long talk with everyone else involved in Nerd Federation (well, less of a talk, more of I am going to tell them later), Nerd Federation has been brought back online but these time as somewhat of a blog portal. That said none of you lower scum will be posting ;). It’s pretty much just myself, Ceon and Rawpulse that get to post entries, though the rest of you can post comments.

Random subjects are always cool and that’s the best thing about a blog. You can just come on and make a post pretty much about anything and yet you still don’t end up with the pointless comments and discussions that you often find on forums, indeed that you used to find on the Nerd Federation forum. If you can find your way past the entry portal page that is!

So prepare to be overwhelmed by fun as we post random comments that just make no sense…

Accessing MySQL with ASP

December 30th, 2003 | Programming, Tech

Being an active server page coder by nature, all my sites are in ASP. So eventually I hit a problem – two sites want to use the same Access database but they are on different hosts. Therefore I decided it would be best to use a MySQL database that they could share by making remote connections.

Why use MySQL?

The main advantage is as I have already mentioned, having a central MySQL database allows you to connect all your sites directly to it and access the information. There are ways to do this in Microsoft Access but they are patchy at best. The other option would be to use MS SQL server although this doesn’t come cheap from any host.

Changing the code

Let’s say for example I have a MySQL database on a linux hosting account at www.examplelinux.com. And I have a website at www.examplewindows.com that I want to connect with. Luckily connecting to MySQL is similar to any other connection except we just need to make a few changes.

The first is obvious; the connection script needs to be changed as we are accessing MySQL rather than an Access database. The second are certain changes in the scripts to make sure we don’t end up with any MySQL errors.

A typical DNS less connection would be something like:

Driver={Microsoft Access Driver (*.mdb)}; DBQ=" + Server.MapPath("/Conndb/springer1.mdb")

Whereas a connection to MySQL would look more like:

Driver={MySQL ODBC 3.51 Driver}; Server=examplelinux.com; Database=dbname; UID=username; PASS=password

To do this your server needs to have the MySQL driver on it. You can download it from http://www.mysql.com/downloads/index.html. You can also use a DNS connection if you have one which makes things considerably simpler:

DSN=linuxexampledns

All you need to do is replace the connection line you currently use with the new one modifying the username, password and name of the database you are going to use on your target server.

Further modifications

To make the ASP code work with MySQL there are a few other modifications you need to make with your code. The problem arises from the use of the ‘ character. Where Access is ok with it, MySQL will bring up a nice big error message.

Luckily a bit of PHP style code can come to the rescue. If you are familiar with PHP, you will know you can remove the significance of a character using \ before it. Therefore a quick replace function does the trick

Replace(string, "'", "\'")

So for instance a select command would go from:

SELECT * FROM hobbies WHERE firstname = '" + (users.Fields.Item("firstname").Value) + "' ORDER BY name ASC

And changed to:

SELECT * FROM hobbies WHERE firstname = '" + Replace((users.Fields.Item("firstname").Value) ,"'","\'") + "' ORDER BY name ASC

Setting up the server

Once the modifications to the code have been made you can get on with setting up the server to accept the requests. First of all you need to allow the scripts to access the database.

In CPanel goto MySQL Database and scroll down to access hosts: then add in the IP address of www.windowsexample.com. If you can’t find it out, simply run the scripts and it will bring you up an access denied message containing the IP address you are trying to access the database from.

In Direct Admin goto MySQL Databases, click on the database and then you can enter the IP address in to the access hosts form near the bottom. If you can access the privileges section in phpMyAdmin directly you can also do it from there as you can set for each user what access host the user can use.

The only other problem is getting the contents of your Access database to your MySQL server. The easiest way I found to do this way to set up a DNS connection to the MySQL server on my local machine, though you may be able to do this directly to the server providing you grant yourself access, and then going into Access and Exporting it.

File > Export then open the drop down menu at the bottom and and scroll to the bottom of the list until you see ODBC Databases (). This will close the export window and prompt you to enter the name of what you want to call it when you export it. Most likely it will be best to leave the default here.

Then it will come up with a box asking you to select a data source. Select the machine data source tab and find your DNS connection on the list then click ok and your done.

Conclusion

Switching your database from Access to MySQL is a hassle – you need a Linux server, code changes and connection scripts. However if your sites need to share a database its a far cheaper option that using MS SQL.

Printer friendly pages

October 18th, 2003 | Programming, Tech

There is nothing like reading an article on the website and finding it one of the best you have ever read – you immediately want to show to it other people. You flick the switch on your printer to on, hit Control + P and prepare for it to emerge. But what do you get? A mess of DHTML, adverts or half the text missed off the edge of the page.

You could always hope the visitor turns their page to landscape but with the length web pages usually turn out like it is not very likely. Save them the trouble of having to print selection or copy and paste into a word processing package by making your pages printer friendly for them to print straight from.

Making them friendly in the first place
There are two main ways to allow visitors to print the pages easily. The first is to make the original web page with the article or content on, the right size to be able to print. For liquid width sites this is ok as long as they can condense down although for fixed width sites this is not as easy.

Generally you have a width of about 600 pixels, which the users printer will print. This is good if you have a navigation or sky scraper advert down the site taking the last 200 pixels of your page as the user does not need these printing. Although if your article goes all the way to the edge its time to rethink the design.

One way of getting round this would be to have a link, which chances the width of the page. The user clicks a link to say somepage.php?mode=printer. Then you could have something, which says if the mode is set to printer the page width is altered to 600 rather than 800 pixels using server side scripting. This could also be done to a certain extent using JavaScript so the page will not always have to be reloaded although in some browsers it may have to be and there is more chance of it going wrong.

The printer friendly page

This is a more common solution to the problem of visitors not being able to print. All you have to do is set up a separate page without all your adverts, logos and navigation, which is less wide or uses a liquid width so that the user can print this.

Generally you wont want to include adverts on this page, otherwise visitors may not use it at all as they can remove the ads themselves using print selection or copy and pasting the text. However you may want to include your logo and visitors won’t mind and it increases branding when the article is passed around.

If your articles are static then you may end up creating a separate page for each of these but if your articles are dynamic, most likely stored in a database you will simply be able to make a dynamic page just like your main article page for the printer friendly page and link them together.

Making it usable

Whatever solution you use you may want to include a print link to. This will encourage users to print the article simply by clicking the link, as their finger will already be on the mouse button, so users who would not normally print the article may give it a click.

Another good point about users printing the whole page rather than copy and pasting the text into a word processor is that the URL of the page will be at the bottom so other people who read it will see it and when the visitor looks at it later they will remember your website.

Intellectual property and protest sites

October 12th, 2003 | Life, Tech

A lot of people are using the internet to speak out against the companies that they object to. From the global protest sites such as www.stopesso.com to the small one man operations, protest sites are springing up all over the net. But can it be done without attracting a ball of law suites?

Starting these websites can be a problem on two fronts. The first problem is that if you start printing lies about the company they wouldn’t be happy about you bad mouthing them. The second is that if you register a domain such as www.xyzsucks.com are you breaking the trademark of xyz?

The first problem is easily to solve – don’t say anything unless you can prove it. First of all making up lies isn’t going to help the site as it will discredit it if it is discovered to be a lie and secondly it’s not really fair on the company. Which is why the can sue you if you start publishing lies. Stick to the truth of why you don’t like them though and they pretty much cannot touch you.

As for the second problem there is always the solution of not using the companies name in the website name but then how will people know the site is about that company? The good news is this is not a criminal act so even if the company does get angry, police are unlikely to come round knocking on your doors.

As huumor pointed out on one of my favourite web developer forums:

“if you hate McDonald’s and make a “hate” site called www.McDonaldsSucks.com – you are probably more likely going to be #”¤#&”¤-ed by McDonalds lawyers than if you would use www.CrapDonalds.com – with this domain name you’re not using the copyrighted McDonald’s in it…”

The problem is going to come from ICANN’s decisionon whether you can keep the domain or not. Some sites including www.walmartcanadasucks.com have been allowed to keep the names whereas a recent Reg Vardy protest site had its domain handed over to the company.

There is no clear rule on this one although running a search on The Register throws up some interesting results.

Does my business need .biz?

August 1st, 2003 | Programming, Tech

Until now companies had it pretty easy. You choose a .com domain although if you were a British company you may have had to choose between a .co.uk as well. Times like that are gone now however. Now businesses have to pick between extensions including .biz for all companies and .us for US companies.

The problem is that nobody wants an unpopular extension and if dot biz does not take off many businesses could be stranded with a useless domain. Although dot biz are gradually becoming more popular and its not lucking like one that will fade out any time soon; although the best option is often to play it safe.

Dot biz problems

Domain extensions have been launched many times with the hope of climbing to the success of the dot com. But none of them have done and my guess is that none of them will do any time soon. To be popular you had to be quick off the mark.

Dot net and not org were popular as they are very widespread and .co.uk has done very well too as it was out well before it was all the crazy to bring out your own domain extensions for your country. Back when nobody hard heard of dot tv, dot ca and dot us, .co.uk were selling like hot cakes; making them very cheap helped too.

The problem is though that dot biz was not quick off the mark. And many of the big websites had already set up sites when the dot biz sales doors where opened for business. Many large corporations who could have promoted dot biz already had dot com’s by then and were not about to change.

The dot com seems like the perfect extension too. It is spelt like it sounds, its not too short and its not too long. The problem with dot biz is that unless it becomes very popular people could easily confuse the spelling with bis. And no business wants some of its website traffic heading off to an address which does not exist.

Those names though

As will any new extension however people will be tempted by the fact they can get find a name shorter than a paragraph in length which hasn’t been snapped up already. While people are cueing up on services like SnapBack to get stupidly long dot com domains, it’s easy to find a great name that ends in dot biz.

There is no localisation on dot biz as with many other domains neither. For instance owning a dot us is great and your website visitors will love it – providing they all come from the US. But chances are they won’t be, and people who don’t live in the area your name is from could feel like an outsider. This is not a problem with names like dot tk as everyone feels like an outsider together ;). I mean how did an island that small get an internet connection let alone a domain name extension in the first place?

Conclusion

If your company name is available in a dot com then go for a dot com. Dot com is still and for a while yet will be the dominant name. However if you can’t get it then a dot biz looks professional and chances are you can get your name. If so I recommend that you go for it. After all the dot biz popularity grows every time a registration is made.