Archive for January, 2008

Display textarea content with line breaks in html page

Let us see how javascript, php, and ruby display the content of textarea with line breaks

Javascript:

document.getElemnetById(‘textareacontent’).value.replace(/\n/g,'<br>’);

PHP:

preg_replace(“/\n/”,”<br>”,$_REQUEST[‘t1’]);

Ruby:

(teaxtareacontent).gsub(/\n/,”<br>”)

January 31, 2008 at 12:21 pm 2 comments

PHP Singleton Object

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

Here is an example, that demonstrates this singleton pattern: (more…)

January 29, 2008 at 1:58 pm Leave a comment

Take the dump of database from the console

To take dump of whole database:
$ mysqldump -u <username> -p <databasename> > <filename>.sql

To take dump of the (only)structure of the database
$ mysqldump -u <username> -p <databasename> -d > <filename>.sql

To take dump of the (only)data of the database
$ mysqldump -u <username> -p <databasename> -t > <filename>.sql

To take dump of the database with complete insert statement
$ mysqldump -u <username> -p <databasename> -c > <filename>.sql

January 23, 2008 at 8:09 am 2 comments

How to create database using mysql commands

To create database from command prompt. Login to mysql as root user.
To login into mysql prompt in linux machine.
Type the following command in the console

$ mysql -u <username> -p<password>

After entering the mysql prompt follow these steps to create a database
and load the database with sql file.

A CREATE DATABASE statement to create a database.
> create database <databasename>;

A GRANT statement to grant privileges to database.
> grant all on <databasename>.* to <username>@localhost identified by ‘<password>’;

A FLUSH PRIVILEGES statement to tell the server to reload the grant.
> flush privileges;

A USE statement to tell the server to use the given database for further operations.
> use <databasename>;

A SOURCE statement to tell server to load the given sql file in the database.
> source <filename.sql>

January 8, 2008 at 9:39 am 1 comment


Pages

Blog Stats

  • 33,745 hits
January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

Twitter Updates

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

religion and spirituality