Posts

Showing posts from October, 2008

Html performance

HTML is a very flexible language. It never generates errors, and often provides many different ways to accomplish a single task. For example, a list item can be specified as <LI>description or <LI>description</LI>. The only difference is the closing </LI> tag, but it might be biggest mistake. If these tags don't close, the browser renders pages just fine. But if tags are closed then it will render the pages even faster. Take a look at the following code segment: <P>Here is a list of names: <UL> <LI>Kanpur <LI>Jhanshi <LI>Lucknow <LI>Pune <LI>Bangalore </UL> In above example, the <P> and <LI> items are included without their closing counterparts. When parsing such HTML code, the browser needs to look ahead to find out where the paragraph or list item ends. The following code generates the same output in a more efficient method: <P>Here is a list of names :</P> <UL> <LI>Kanpu...

Mysql Prompts

You can change the prompt on the MySQL command-line tool to show user name, time, current database or many other useful facts. mysql> prompt \R:\m:\s> PROMPT set to '\R:\m:\s>' 11:46:16>show tables; +----------------------+ | Tables_in_wordpress | +----------------------+ | wp_categories | | wp_comments | | wp_linkcategories | +---------------------+ 9 rows in set (0.00 sec) 11:46:24> If you specify the prompt command with no argument, mysql resets the prompt to the default of mysql> . The prompt command reconfigures the default mysql> prompt. The string for defining the prompt can contain the following special sequences: Option Description \c A counter that increments for each statement you issue \D The full current date \d The default database \h The server host \l The current delimiter (new in 5.0.25) \m Minutes of the current...

isset for javascript

try{ if(variablename){ // If true // write your code here } }catch(e){ //If false // write your code here if false }

Mass Replace String in MySQL Database

Problem: I want to change url path or a string from mysql table. Solution: Do it manually? No way. There are hundreds of them! There are basically two ways - First, output the database table and use text editor's "search and replace" function. Second, use MySQL REPLACE function . Here is the SQL query to replace string in database table :- UPDATE table_name SET column_name = REPLACE ( column_name, "original_string" , "replace_string" );

Download multiple files from FTP

Problem : When we download multiple file from command line ftp, it prompt for every file. Solution: ftp> prompt ftp> mget *.* or ftp> mget

Mysql:Reset Auto increment No.

I have a database table with a auto increment column for primary key. As the records being add and delete many times, the auto increment value will keep increasing. Problem One: I want to delete all data from table. Solution: TRUNCATE table tbl_name this command will delete everything from the table and start again from 1.... DELETE just does the same but keeps the current auto_increment value.... Problem Two: If I have entered 10 records, and deleted 9th, 10th records. The next auto increment value will be 11, not 9. Solution: Run a query: ALTER TABLE tablename AUTO_INCREMENT = 1 This will reset the next auto increment value to current largest value in the auto increment column + 1. So, the auto increment value of next inserted record will start from 9. Problem Three: If I have entered 10 records, and deleted center records - 4th, 5th. I want to insert next record as 4th not 11th. Solution: Run the following query: SET insert_id = 4; INSERT INTO tablename VALUES (’blah’, ‘…’);...