Friday, November 12, 2010

Importing Large db file in easiest way

hi..
I found one easy solution to upload large db files through phpmyadmin..

1. Go to C:\xampp\phpMyAdmin
2. create one folder there. name it as upload.
3. now open the file C:\xampp\phpMyAdmin\config.inc.php
4. add this line in that file $cfg['UploadDir'] = 'upload';
$cfg['ExecTimeLimit'] = 0;
5. now add your db sql file to upload folder.

and you are done now.
now go to phpmyadmin.. you will find web server upload directory drop down there.
select that file then Go.......and you are done

Monday, November 1, 2010

Javascript trim function

Many of us aware of trim function in php.
but there is no direct trim function in js if we want to use it.
following is the code for trim function in JS.


function trim10 (str) {
var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
for (var i = 0; i < str.length; i++) {
if (whitespace.indexOf(str.charAt(i)) === -1) {
str = str.substring(i);
break;
}
}
for (i = str.length - 1; i >= 0; i--) {
if (whitespace.indexOf(str.charAt(i)) === -1) {
str = str.substring(0, i + 1);
break;
}
}
return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

You can call it as
msg=trim10(" Bhupendra ");

and you will get o/p as msg="Bhupendra"
very easy...isn't it?