News & Blog

MySQL Ignoring Small Words in Full-Text Search Using MATCH AGAINST

September 23rd, 2012 - Posted by Steve Marks to Web Development.
I’ll start by jumping right in and providing an example of a scenario where search terms of a short length (less than four characters to be precise) might not be included in a MySQL query when using Full-Text searching and MATCH() AGAINST(). Let’s imagine we have the following ...

PHP Function to Compare Floating Point Numbers

September 14th, 2012 - Posted by Steve Marks to PHP, Web Development.
If you’ve found this post you’re probably, like I once did, experiencing problems with comparing floating point numbers in PHP. A section on the official PHP website confirms the difficulty in doing this and why it can be problematic. And I quote… As noted in the warning ...

Format a Number Within a String Using PHP preg_replace() Function

September 14th, 2012 - Posted by Steve Marks to PHP, Web Development.
Let’s imagine we have the following string: I owe 1000000 GBP to the bank. I shall pay 2500 GBP each month for the following 1000 years. The above statement is luckily not true, however it is a good representation of a scenario where we have numbers contained within a string that we ...

Stop Adobe Dreamweaver Hanging or Freezing on Large Files

September 6th, 2012 - Posted by Steve Marks to Software, Web Development.
Whilst recently working on an application in Adobe Dreamweaver that contained lots of very large files, each containing tens of thousands of lines, I kept running into a problem where Dreamweaver would stop, hang, freeze and even sometimes stop responding when I tried to do anything. This ...

PHP Benchmark: Multiple str_replace() vs One str_replace() With Array

September 5th, 2012 - Posted by Steve Marks to PHP, Web Development.
I’m a massive fan of optimisation. Inparticular I’m talking about optimising PHP code, rather than, say, HTML code which would improve a users experience. Sometimes however I think it can go too far when it comes to doing something that results in saving just a few milliseconds...

How to Order GROUP_CONCAT() Values in MySQL

September 1st, 2012 - Posted by Steve Marks to MySQL, Web Development.
When performing a GROUP_CONCAT() in a MySQL query you might notice that the results come back in no particular order, or to be precise, in the same order as if you ran the query without the GROUP_CONCAT(). Let’s take the following SQL to create our test scenario: CREATE TABLE `animal...

POST Data From a Form To An iFrame

July 28th, 2012 - Posted by Steve Marks to (X)HTML / CSS, Web Development.
You’re probably used to submitting forms to the same page or to a new window by setting the target of a form to ‘_self’ (or not setting a ‘target’ attribute) or ‘_blank’. If you use iFrames however, be it as an interface element or a hidden element...

Remove BODY onunload Event After Page Has Loaded

July 26th, 2012 - Posted by Steve Marks to (X)HTML / CSS, Javascript / jQuery, Web Development.
The onunload can be used to perform an action or to call a function when the user leaves a webpage. There are scenarios however when you might want to remove this action after the page has loaded. Take a look at the simple example below where I present a very basic HTML page containing an ...

MySQL Error Resolved – Subquery Returns More Than 1 Row

July 26th, 2012 - Posted by Steve Marks to MySQL, Web Development.
If you’ve found this post you’re probably trying to find out why your MySQL query is returning the following error: Subquery returns more than 1 row To allow me to explain the problem let me show you an example of a query that might throw this kind of error: SELECT `col1` FROM ...

Ordering By Multiple Columns in an SQL Query

July 26th, 2012 - Posted by Steve Marks to MySQL, Web Development.
I remember when I started coding and writing SQL, one of the very first things I had to look up was how to order an SQL resultset by multiple columns. Let me dive right in and provide some examples… Ordering by a single column SELECT `col1` FROM `tablename` ORDER BY `col1` Ordering b...