Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Monday, February 28, 2011

Deleting Duplicate Rows in a MySQL Database

Assuming the following bad table design:
CREATE TABLE bad_table2 (
id INT NOT NULL UNIQUE AUTO_INCREMENT,
name VARCHAR(20) NOT NULL
);

INSERT INTO bad_table2(id,name) VALUES
(1,'Things Fall Apart'),
(2,'Things Fall Apart'),
(3,'The Famished Road'),
(4,'Things Fall Apart'),
(5,'The Famished Road'),
(6,'Thirteen cents'),
(7,'Thirteen cents');

I can remove duplicates easily with the following line:
alter ignore table bad_table2 add unique index `unique_index` (name);

And then remove the added index.
alter table bad_table2 drop index `unique_index`;

Source: Comment by Paul Swarthout @ databasejournal.com

Monday, February 7, 2011

Enable Classic ASP custom error pages

After days of searching the web and nagging my host i finally came across this piece of code from here

It was just what i needed to show classic ASP custom error pages using the config file

<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <httpErrors> <remove statusCode="500" subStatusCode="100" /> <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error-500.asp" responseMode="ExecuteURL" /> </httpErrors> </system.webServer></configuration>

Wednesday, February 2, 2011

Javascript: reversing a string


function strrev(str)
{
if (!str) return '';
var revstr='';
for (i = str.length-1; i>=0; i--)
revstr+=str.charAt(i)
return revstr;
}

alert(strrev("Hello World!"));


OR alternatively you can use split("") to
convert a string to an array, reverse() to
reverse the array, and join("") to convert
it back.

function strrev(str)
{
return str.split("").reverse().join("");
}

alert(strrev("Hello World!"));

Chitika Ads