Backup Your MySQL Database Using PHP

Here is the script to backup MySql database using php. Cheers!

// Check via PhpMyAdmin to see what character database is using
mysql_query('SET NAMES utf8');
mysql_query('SET CHARACTER SET utf8');
$tables = '*';
//get all of the tables
if($tables == '*')
    $tables = array();
    $result = mysql_query('SHOW TABLES');
    while($row = mysql_fetch_row($result)) {
    $tables[] = $row[0];
    $tables = is_array($tables) ? $tables : explode(',',$tables);
//cycle through
foreach($tables as $table)
    $result = mysql_query('SELECT * FROM '.$table);
    $num_fields = mysql_num_fields($result);
    $return.= 'DROP TABLE '.$table.';';
    $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
    $return.= "\n\n".$row2[1].";\n\n";
    for ($i = 0; $i < $num_fields; $i++)
        while($row = mysql_fetch_row($result))
            $return.= 'INSERT INTO '.$table.' VALUES('; for($j=0; $j<$num_fields; $j++) { $row[$j] =             addslashes($row[$j]);
            $row[$j] = ereg_replace("\n","\\n",$row[$j]);
            if (isset($row[$j]))
                $return.= '"'.$row[$j].'"' ;
                $return.= '""';
            if ($j<($num_fields-1))
                $return.= ',';
        $return.= ");\n";
//save file
$handle = fopen('backups/db-backup-'.date('Y-m-d H:i:s').'-'.(md5(implode(',',$tables))).'.sql','w+'); fwrite($handle,$return); fclose($handle); if($handle)
    echo "database is successfully stored in backups directory.";
    echo "database backup unsuccessfuly.";

What do you mean by data warehouse? Explain the query manager.

Data Warehouse :

In computing, a data warehouse (DWDWH), or an enterprise data warehouse (EDW), is a system used for reporting and data analysis. Integrating data from one or more disparate sources creates a central repository of data, a data warehouse (DW). Data warehouses store current and historical data and are used for creating trending reports for senior management reporting such as annual and quarterly comparisons.

The data stored in the warehouse is uploaded from the operational systems (such as marketing, sales, etc., shown in the figure to the right). The data may pass through an operational data store for additional operations before it is used in the DW for reporting.

A data warehouse maintains a copy of information from the source transaction systems. This architectural complexity provides the opportunity to :

  • Congregate data from multiple sources into a single database so a single query engine can be used to present data.
  • Mitigate the problem of database isolation level lock contention in transaction processing systems caused by attempts to run large, long running, analysis queries in transaction processing databases.
  • Maintain data history, even if the source transaction systems do not.
  • Integrate data from multiple source systems, enabling a central view across the enterprise. This benefit is always valuable, but particularly so when the organization has grown by merger.
  • Improve data quality, by providing consistent codes and descriptions, flagging or even fixing bad data.
  • Present the organization’s information consistently.
  • Provide a single common data model for all data of interest regardless of the data’s source.
  • Restructure the data so that it makes sense to the business users.
  • Restructure the data so that it delivers excellent query performance, even for complex analytic queries, without impacting the operational systems.
  • Add value to operational business applications, notably customer relationship management (CRM) systems.
  • Making decision–support queries easier to write.

Query Manager : 

The query manager the system component that performs all the operations necessary to support the query management process. The system is typically constructed using a combination of user access tasks, data warehousing monitor tools , native database facilities and shell script.

The architecture of query manager perform following operations :

– Direct queries to the appropriate table

– Schedule the execution of the user queries

What is data mining? What are the functions of data mining? Write about association analysis with an example.

Data Mining :

Generally, data mining (sometimes called data or knowledge discovery) is the process of analyzing data from different perspectives and summarizing it into useful information – information that can be used to increase revenue, cuts costs, or both. Data mining software is one of a number of analytical tools for analyzing data. It allows users to analyze data from many different dimensions or angles, categorize it, and summarize the relationships identified. Technically, data mining is the process of finding correlations or patterns among dozens of fields in large relational databases.

Data mining is primarily used today by companies with a strong consumer focus – retail, financial, communication, and marketing organizations. It enables these companies to determine relationships among “internal” factors such as price, product positioning, or staff skills, and “external” factors such as economic indicators, competition, and customer demographics. And, it enables them to determine the impact on sales, customer satisfaction, and corporate profits. Finally, it enables them to “drill down” into summary information to view detail transactional data.

Functions of Data Mining :

1. Class Description
2. Association
3. Classification
4. Prediction
5. Clustering
6. Time-series analysis

Association Analysis :

The purpose of association analysis is to find patterns in particular in business processes and to formulate suitable rules, of the sort “If a customer buys product A, that customer also buys products B and C”.

Tip : If a customer buys mozzarella at the supermarket, that customer also buys tomatoes and basil.

Association analysis also helps you to identify cross-selling opportunities, for example. You can use the rules resulting from the analysis to place associated products together in a catalog, in the supermarket, or in the Web shop, or apply them when targeting a marketing campaign for product C at customers who have already purchased product A.
Association analysis determines these rules by using historic data to train the model. You can display and export the determined association rules.

Rakshabandhan (रक्षाबन्धन)

हिन्दुहरूको धार्मिक तथा साँस्कृतिक पर्व जनै पूर्णिमा नयाँ यज्ञोपवित धारणा तथा रक्षा-बन्धन गरी धुमधामका साथ मनाइन्छ । तागाधारी जातिले अघिल्लो दिनदेखि नै चोखोनितो गरी एक छाक खाने, आजका दिन बिहानै नदी, तलाउमा गई गाईको गोबर तथा तुलसीको माटो लगाई नुहाउने तथा जौ, तिल, कुशद्वारा ऋषितर्पणी गरी वैदिक विधिपूर्वक मन्त्रिएको नयाँ जनै (यज्ञोपवित) फेर्ने चलन रहेकाले यस पर्वलाई जनै पूर्णीमा भन्ने गरिएको हो । सत्ययुगमा दानवद्वारा लखेटिएका देवगणलाई गुरु बृहस्पतिले रक्षा विधान तयार गरी जे चिजले अत्यन्त बलशाली दानवराज बलि बाँधिए, त्यसले नै म तिमीलाई बाँध्छु, यसले तिमी सुरक्षित वन, विचलित नहोऊ भनी डोरो बाँधेर जोगाएका थिए भन्ने पौराणिक मान्यताका आधारमा चलेकोे रक्षाबन्धनको परम्परा आज पनि प्रचलित छ ।

यसैकारण रक्षाबन्धन गर्ने बेलामा गुरु पुरोहितले

“येन बद्धो बलिराजा दानवेन्द्रो महाबल तेन त्वाम् प्रतिबध्नामी रक्षेमा चलमा चल”

भनी रक्षासूत्र रक्षाबन्धन अथवा डोरो बाँध्ने वैदिक परम्परा रहिआएको छ । मानव रक्षाका लागि जप, तप र पूजा गरी मन्त्रिएको रक्षाबन्धन वैदिक परम्पराको मन्त्रोच्चारण गर्दै ब्राहृमण पुरोहितले यजमानको नाडीमा बाँधिदिने परम्परा छ ।

रक्षाबन्धन मर्यादा र आत्मा निग्रहद्वारा मृत्युमाथि विजय प्राप्त गर्ने पर्व हो । रक्षासूत्रको बन्धन र टिका यस उत्सवको प्रमुख विधान हो । सूत्र आत्माको मयादा र संयमको प्रतीक हो र टिका आत्म स्वरुप स्थितिमा स्थित हुने प्रतीक हो । सूत्र कुनैपनि वस्तुलाई अविच्छिन गर्ने वस्तु हो । सुनियोजित एवं सुव्यवस्थित वस्तु एक सूत्रमा ग्रथित मानिन्छ । रक्षाबन्धनको सही अर्थ आफू आत्म स्थितिमा अचल, अडोल भएर पवित्रताको पालन गर्नु हो किनकि पवित्रताद्वारा नै मृत्युमाथि विजय प्राप्त गर्न सकिन्छ ।

Famous Quotes From the Legendary Robin Williams

Robin McLaurin Williams (July 21, 1951 – August 11, 2014) was an American actor and comedian. Rising to fame with his role as the alien Mork in the TV series Mork & Mindy (1978–82), Williams went on to establish a successful career in both stand-up comedy and feature film acting.

The death of Robin Williams silenced one of Hollywood’s most famous voices.

Robin Williams Famous Quotes :

  • No matter what people tell you, words and ideas can change the world.
  • You’re only given a little spark of madness. You mustn’t lose it.
  • You’re only given one little spark of madness. You mustn’t lose it.
  • God gave men both a penis and a brain, but unfortunately not enough blood supply to run both at the same time.
  • If women ran the world we wouldn’t have wars, just intense negotiations every 28 days.
  • I left school and couldn’t find acting work, so I started going to clubs where you could do stand-up. I’ve always improvised, and stand-up was this great release. All of a sudden, it was just me and the audience.
  • You have this idea that you’d better keep working otherwise people will forget. And that was dangerous.
  • Reality is just a crutch for people who can’t cope with drugs.
  • You’re only given a little spark of madness. You mustn’t lose it.
  • Never pick a fight with an ugly person, they’ve got nothing to lose.
  • I’m sorry, if you were right, I’d agree with you.

Rest In Peace Robin Williams!

Explain the importance of IP addressing and how can you classify it to represent IP address.

An IP address is an address used to uniquely identify a device on an IP network. The address is made up of 32 binary bits which can be divisible into a network portion and host portion with the help of a subnet mask. The 32 binary bits are broken into four octets (1 octet = 8 bits). Each octet is converted to decimal and separated by a period (dot). For this reason, an IP address is said to be expressed in dotted decimal format (for example, The value in each octet ranges from 0 to 255 decimal, or 00000000 – 11111111 binary.

Classification of IP Address

In a Class A address, the first octet is the network portion, so the Class A has a major network address of – Octets 2, 3, and 4 (the next 24 bits) are for the network manager to divide into subnets and hosts as he/she sees fit. Class A addresses are used for networks that have more than 65,536 hosts (actually, up to 16777214 hosts!).

In a Class B address, the first two octets are the network portion, so the Class B has a major network address of – Octets 3 and 4 (16 bits) are for local subnets and hosts. Class B addresses is used for networks that have between 256 and 65534 hosts.

In a Class C address, the first three octets are the network portion.
The Class C has a major network address of – Octet 4 (8 bits) is for local subnets and hosts – perfect for networks with less than 254 hosts.

Network Masks:
A network mask helps you know which portion of the address identifies the network and which portion of the address identifies thenode. Class A, B, and C networks have default masks, also known as natural masks, as shown here:
Class A: —–/8
Class B: —/16
Class C:–/24

What are the different types of disasters? Explain in brief how can you develop disaster recovery plan?

The different types of disasters can be classified into two categories. They are:

Natural disasters
A natural disaster is a major adverse event resulting from the earth’s
natural hazards. Examples of natural disasters are floods,
tsunamis, tornadoes, hurricanes/cyclones, volcanic
eruptions, earthquakes, heat waves, and landslides.

Man-made disasters
Man-made disasters are the consequence of technological or human
hazards. Examples include stampedes, urban fires, industrial
accidents, oil spills, nuclear explosions/nuclear radiation and acts
of war.

Develop disaster recovery plan

Step1: Risk Analysis
The first step in drafting a disaster recovery plan is conducting a
thorough risk analysis of our computer systems. List all the possible
risks that threaten system uptime and evaluate how imminent they are in our particular IT shop.

Step 2: Establish the Budget
Once you’ve figured out your risks, ask ‘what can we do to suppress them, and how much will it cost?’

Step 3: Develop the Plan 
The feedback from the business units will begin to shape your DRP procedures. The recovery procedure should be written in a detailed plan or “script.” Establish a Recovery Team from among the IT staff and assign specific recovery duties to each member and Define how to deal with the loss of various aspects of the network and specify who arranges for repairs or reconstruction and how the data recovery process occurs.

Step 4: Test
Once your DRP is set, test it frequently. Eventually you’ll need to
perform a component-level restoration of your largest databases to get a realistic assessment of your recovery procedure, but a periodic
walk-through of the procedure with the Recovery Team will assure
that everyone knows their roles.

Why to choose symfony

I never gone too much deep over the symfony. However, I experienced it for one of my project. Adhering to an MVC pattern and strict object oriented language Symfony framework allows creating more testable code which can be reused in future and accordingly saves the time.

Choosing Symfony means having a long-term vision of application assets. It also means knowing how to make the day-to-day life of developers much easier.

The advantages of using symfony framework and the answers for the question why to choose symfony are:

1. Empowers Developers :

By taking features that would have previously have taken 100’s of lines of code and compressing them into one simple function call empowers developers to integrate more complex features into their Web Sites.
2. Allow for Quicker development of applications :

This is very relevant for people that need websites created in a very small window .

3. Lower Costs :

Allows programmers to pass cost savings onto the customer, a whole new range of customers generated that wanted a website but previously could not afford the higher development costs.

4.  Symfony tries to bring innovation to PHP:

It was one of the first major frameworks to embrace PHP 5.3, to introduce the usage of a Dependency Injection container, and to use a templating engine for its templates by default, Twig, which is now also adopted by major CMSes like Drupal and eZpublish. Symfony also has some unique features like its gorgeous debug toolbar and its great built-in profiler.


A very first program in c++ with the concept of class

using namespace std;

class person
char name[20];
int age;

void getdata(void);
void dislpay(void);
void person :: getdata(void)
cout<<"Enter name:";
cout<<"Enter age:";
void person :: display(void)
cout<<"\nName: "<
cout<<"\nAge: "<
int main()
person p;


return 0;

Difference between object-oriented programming (OOP) and procedure-oriented programming (POP)

Difference between object-oriented programming (OOP) and procedure-oriented programming (POP) :

Emphasis on doing things (procedure). Emphasis on data rather than procedure.
Programs are divided into what are known as functions. Programs are divided into what are known as objects.
Data move openly around the system from function to function. Data is hidden and cannot be access by external functions.
Employs top down approach in the program design. Employs bottom up approach in program design.

Web Enthusiastic, Nature Lover