Ignore break ( <br /> ) tags with CSS

I just ran across a problem where I needed to ignore/disable <br> tags. Here’s the situation - I use CSS to spice up my <code> tags in this blog, but when I add new entries it adds a <br /> after every line feed; this normally wouldn’t be a problem but I use ‘white-space: pre’ to keep my code indents. white-space: pre is like using a <pre> tag for your element, so both line feeds and <br /> tags are converted to new lines. »

stevekamerman

Storing IP Addresses in MySQL with PHP

I’ve seen a lot of people trying to store IP Addresses in MySQL VARCHAR fields - this is very inefficient! There are two common ways to store ips that are database friendly: as a hexidecimal number and as a long integer. I recommend the long integer method since this functionality is already implemented in PHP. Here’s how it’s done: Make a column in MySQL to store the ip address. Give it the type INT(11). »

stevekamerman

MySQL 5 Stored Procedures - Practical Example

I have come up with a practical use for MySQL Stored Procedures and developed a very useful example for the sceptics. The following is a MySQL SP that calculates the distance between two ZIP codes - all you pass it is the zip codes! This code assumes you have a database of US ZIP Codes with their Longitudes and Latitudes. MySQL CODE DELIMITER // CREATE PROCEDURE `zipDist`(zipA INT, zipB INT) BEGIN DECLARE latA DECIMAL(10,6); DECLARE lonA DECIMAL(10,6); DECLARE latB DECIMAL(10,6); DECLARE lonB DECIMAL(10,6); SELECT latitude, longitude INTO latA, lonA FROM zipcodes WHERE zip=zipA; SELECT latitude, longitude INTO latB, lonB FROM zipcodes WHERE zip=zipB; SELECT ACOS(SIN(RADIANS(latA)) * SIN(RADIANS(latB)) + COS(RADIANS(latA)) * COS(RADIANS(latB)) * COS(RADIANS(lonB) - RADIANS(lonA))) * 3956 AS distance; END// DELIMITER ; Using this stored procedure in your code will save you 2 MySQL queries and a little bit of math in your code. »

stevekamerman