Beruflich Dokumente
Kultur Dokumente
http://info@abc.com
using regular expression of PHP?
A:5 preg_match(/^http:\/\/.+@(.+)$/,http://info@abc.com,$found);
echo $found[1];
Q:6 How can we create a database using PHP and MySQL?
A:6 We can create MySQL database with the use of
mysql_create_db(Database Name)
2. mysql_fetch_array
3. mysql_fetch_object
include() does not behave this way, the script will continue regardless.
4. mysql_fetch_assoc
Q:2 In how many ways we can retrieve the data in the result set of
MySQL using PHP?
A:2 You can do it by 4 Ways
1. mysql_fetch_row.
Q:9 What are the different tables present in MySQL, which type of
table is generated when we are creating a table in the following
syntax:
create table employee (eno int(2),ename varchar(10)) ?
A:9 Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
Questions :
2
What are the differences between PHP3 and PHP4 and PHP5 ?
what is the current stable version of PHP ? what advance thing
in php6
ENCODE() DECODE()
DES_ENCRYPT()
DES_DECRYPT()
ENCRYPT()
Not available
MD5()
Not available
OLD_PASSWORD()
Not available
PASSWORD()
Not available
UNCOMPRESSED_LENGTH()
Answers : 2 The current stable version of PHP is PHP 5.4.5 as still waiting for PHP6
with unicode handlig thing
There are lot of difference among PHP3 and PHP4 and PHP5 version of
php so Difference mean oldest version have less functionality as
compare to new one like
1>PHP3 is oldest stable version and it was pure procedural language
constructive like C
2>Where as PHP4 have some OOPs concept added like class and object
with new functionality
3>and in PHP5 approximately all major oops functionality has been
added along with below thing
1. Implementation of exceptions and exception handling
2. Type hinting which allows you to force the type of a specific argument
3. Overloading of methods through the __call function
4. Full constructors and destructors etc through a __constuctor and
__destructor function
5. __autoload function for dynamically including certain include files
depending on the class you are trying to create.
6 Finality : can now use the final keyword to indicate that a method
cannot be overridden by a child. You can also declare an entire class as
final which prevents it from having any children at all.
7 Interfaces & Abstract Classes
8 Passed by Reference :
9 An __clone method if you really want to duplicate an object
10 Numbers of Functions Deprecated or removed in PHP 5.x like
ereg,ereg_replace,magic_quotes, session_register,register_globals,
split(), call_user_method() etc
Questions :
3
Answer : 3
Questions :
4
Answer : 4
We can connect Mysql Database with PHP using both Procedural and
Object oriented style like below
Questions :
5
In how many ways we can retrieve the data in the result set of
MySQL using PHP? What is the difference between
mysql_fetch_object and mysql_fetch_array ?
Answers : 5 we can retrieve the data in the result set of MySQL using PHP in 4 Ways
1. mysqli_fetch_row >> Get a result row as an enumerated array
2. mysqli_fetch_array >> Fetch a result row as associative and
numeric array
3.mysqli_fetch_object >> Returns the current row of a result set as
an object
4. mysqli_fetch_assoc >> Fetch a result row as an associative array
mysqli_fetch_object() is similar to mysqli_fetch_array(), with one
difference an object is returned, instead of an array. Indirectly, that means that
we can only access the data by the field names, and not by their
offsets (numbers are illegal property names).
Questions :
6
Answers : 6
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for
request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive
request
Questions :
7
Answers : 7 preg_match("/^http:\/\/.+@(.+)$/","http://info@pcds.co.in",
$matches);
echo $matches[1];
Questions :
8
Questions :
9
Answers : 9 Both include and require used to include a file but when included file not
found
Include send Warning where as Require send Fatal Error .
Questions :
12
Questions :
10
Answers :
10
Yes we can use include("xyz.php") more than one time in any page.
but it create a prob when xyz.php file contain some funtions declaration
then error will come for already declared function in this file else not a
prob like if you want to show same content two time in page then must
incude it two time not a prob
Questions :
11
Answers :
11
Answers :
12
The header() function sends a raw HTTP header to a client.We can use
herder()
function for redirection of pages. It is important to notice that header()
must
be called before any actual output is seen..
Questions :
13
Answers :
13
Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.
Questions :
14
Suppose your Zend engine supports the mode <? ?> Then how
can u
configure your PHP Zend engine to support <?PHP ?> mode ?
Answers :
14
In php.ini file:
set
short_open_tag=on
Questions :
15
Answers :
15
Questions :
16
Answers :
16
Inserts HTML line breaks (<BR />) before all newlines in a string.
Questions :
20
Answers :
20
Questions :
21
Answers :
21
encryption
Questions :
17
Answers :
17
Questions :
18
Answers :
18
Questions :
19
Answers :
19
What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs,
servers and
operating systems?
All of those are open source resource. Security of Linux is very
very more than windows. Apache is a better server that IIS both in
decryption
AES_ENCRYT() AES_DECRYPT()
ENCODE()
DECODE()
DES_ENCRYPT() DES_DECRYPT()
ENCRYPT()
Not available
MD5()
Not available
OLD_PASSWOR
Not available
D()
PASSWORD()
Not available
SHA() or
SHA1()
Not available
Not available
UNCOMPRESSED_LENG
TH()
Questions :
22
Answers :
22
Questions :
23
Answers :
23
Questions :
24
Answers :
24
is admitting them. Such functions can use all attributes of the class
which names them as a friend, as if they were themselves members of
that
class.
A friend declaration is essentially a prototype for a member function,
but instead of requiring an implementation with the name of that class
attached by the double colon syntax, a global function or member
function of another class provides the match.
Questions :
25
Questions :
26
Answer : 26 Three are three types of errors:1. Notices: These are trivial,
non-critical errors that PHP encounters while executing a script for
example, accessing a variable that has not yet been defined. By default,
such errors are not displayed to the user at all although, as you will
see, you can change this default behavior.2. Warnings: These are more
serious errors for example, attempting
to include() a file which does not exist. By default, these errors are
displayed to the user, but they do not result in script termination.3.
Fatal errors: These are critical errors for example,
instantiating an object of a non-existent class, or calling a
non-existent function. These errors cause the immediate termination of
the script, and PHP's default behavior is to display them to the user
Questions :
31
How can we get second of the current time using date function?
Questions :
28
Questions :
32
Answer : 32
Answer : 28 Java script submit() function is used for submit form without submit
button
on click call document.formname.submit()
Answer : 29 there are lots of tools available for asp to PHP conversion. you can
search Google for that. the best one is available
athttp://asp2php.naken.cc./
Questions :
33
Questions :
30
Questions :
39
Questions :
34
Answer : 34 unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Questions :
40
Questions :
35
Questions :
36
Answer : 36 To
To
To
To
Questions :
37
know
know
know
know
the
the
the
the
Answer : 37 By using
$_SERVER['HTTP_USER_AGENT']
variable.
Questions :
38
Questions :
41
Answer : 41
Answer : 38 By default the maximum size is 2MB. and we can change the following
setup at php.iniupload_max_filesize = 2M
Questions :
42
Look for the opportunity to introduce index in the table you are
querying.
use limit keyword if you are looking for any specific number of
rows from the result set.
How many ways can we get the value of current session id?
How can we destroy the session, how can we unset the variable
of
a session?
Answer : 47
Questions :
44
Sort(),
asort(),
natsort(),
rsort(),
array_multisort(),
uksort().
arsort(),
ksort(),
natcasesort(),
usort(),
and
Questions :
How can we know the count/number of elements of an array?
48
Answer : 48
2
ways
a) sizeof($urarray) This function is an alias of
count()
b) count($urarray)
Questions :
what is session_set_save_handler in PHP?
49
Questions :
45
Answer : 45
GET/QueryString
POST
Questions :
46
Answer : 46
Answer : 49
Questions : List out some tools through which we can draw E-R diagrams for
51
mysql.
Answer : 51
Case
Smart Draw
Studio
Questions :
List out the predefined classes in PHP?
53
Answer : 53
Questions : How can I retrieve values from one database server and store
52
them
in other database server using PHP?
Answer : 52
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Questions :
55
Answer : 55 Abstract class: abstract classes are the class where one or more
methods are abstract but not necessarily all method has to be abstract.
Abstract methods are the methods, which are declare in its class but
not
define. The definition of those methods must be in its extending
class.Interface: Interfaces are one type of class where all the methods
are
abstract. That means all the methods only declared but not defined. All
the methods must be define by its implemented class.
Questions :
56
Questions :
57
Maximum
Identif
Length
er
(bytes)
Databas
64
e
Table
Questions :
58
Questions :
59
Column 64
Answer : 58 A stored procedure is a set of SQL commands that can be compiled and
stored in the server. Once this has been done, clients don't need to
keep re-issuing the entire query but can refer to the stored procedure.
This provides better overall performance because the query has to be
parsed only once, and less information needs to be sent between the
server and the client. You can also raise the conceptual level by having
libraries of functions in the server. However, stored procedures of
course do increase the load on the database server system, as more of
the work is done on the server side and less on the client (application)
side.Triggers will also be implemented. A trigger is effectively a type of
stored procedure, one that is invoked when a particular event occurs.
For example, you can install a stored procedure that is triggered each
time a record is deleted from a transaction table and that stored
procedure automatically deletes the corresponding customer from a
customer table when all his transactions are deleted.Indexes are used
to find rows with specific column values quickly.
Without an index, MySQL must begin with the first row and then read
through the entire table to find the relevant rows. The larger the
table, the more this costs. If the table has an index for the columns in
question, MySQL can quickly determine the position to seek to in the
middle of the data file without having to look at all the data. If a
table has 1,000 rows, this is at least 100 times faster than reading
sequentially. If you need to access most of the rows, it is faster to
read sequentially, because this minimizes disk seeks.
Answer : 59 The following table describes the maximum length for each type of
identifier.
64
Index
64
Alias
255
Questions :
60
Answer : 60 MySQL set can take zero or more values but at the maximum it can
take 64 values
Questions :
61
Questions :
62
How many tables will create when we create table, what are
they?
Questions :
63
Questions :
64
Questions :
65
Questions :
66
data in a given row, and that every column stores the least amount of
information possible (making the field atomic).Second Normal
FormWhere the First Normal Form deals with redundancy of data across
a
horizontal row, Second Normal Form (or 2NF) deals with redundancy of
data in vertical columns. As stated earlier, the normal forms are
progressive, so to achieve Second Normal Form, your tables must
already
be in First Normal Form.Third Normal Form
I have a confession to make; I do not often use Third Normal Form. In
Third Normal Form we are looking for data in our tables that is not
fully dependant on the primary key, but dependant on another value in
the table
Questions :
67
Disadvantages
This method can not control styles for multiple documents at once
Inline Styles
Questions :
68
Answer : 68
How can we find the number of rows in a result set using PHP?
Advantages
Questions :
69
How many ways we can we find the current date using MySQL?
Questions :
70
Questions :
71
Questions :
72
it should sort the result. If two rows will hawe the same value in col1
it will try to sort them according to col2 and so on.GROUP BY
[col1],[col2],,[coln]; Tels DBMS to group results with same value of
column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if
you want to count all items in group, sum all values or view average
Answer : 72 Primary Key: A column in a table whose values uniquely identify the
rows in the table. A primary key value cannot be NULL.
Unique Key: Unique Keys are used to uniquely identify each row in the
table. There can be one and only one row for each unique key value. So
NULL can be a unique key.There can be only one primary key for a table
but there can be more
than one unique for a table.
Question :
73
Questions :
74
Questions :
76
Answer : 76 Set char to occupy n bytes and it will take n bytes even if u r
storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space
and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store 'romharshan', if each
char
takes a byte
eg. name varchar(15) will just use 5 bytes if we store 'romharshan', if
each
char takes a byte. rest 10 bytes will be free.
Questions
What is the functionality of md5 function in PHP?
: 77
Answer :
77
Answer : 74 Both of them are open source software (so free of cost), support
cross platform. php is faster then ASP and JSP.
Questions
How can I load data from a text file into a table?
: 78
Answer :
78
Questions :
75
{
Questions How can we know the number of days between two
: 79
given dates using
MySQL?
$path = $_SERVER['DOCUMENT_ROOT'] .
"/dataobjects/{$class}.php";
Answer :
79
SELECT DATEDIFF("2007-03-07","2005-01-01");
}
Questions How can we know the number of days between two
: 80
given dates using PHP?
Answer :
80
$date1 = date("Y-m-d");
$date2 = "2006-08-15";
$days = (strtotime($date1) - strtotime($date2)) /
(60 * 60 * 24);
}
}
Answer :
81
by using spl_autoload_register('autoloader::funtion');
spl_autoload_register('autoloader::includesautoloade
r');
Like below
spl_autoload_register('autoloader::daoautoloader');
class autoloader
spl_autoload_register('autoloader::moduleautoloade
r');
{
public static function moduleautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/modules/
{$class}.php";
Questions :
82
Questions :
83
Answers :
83
Answers :
87
Questions :
88
Questions :
84
Answers :
84
Questions :
85
Answers :
85
Answers :
88
Questions :
89
Answers :
89
Questions :
90
Questions :
86
Answers :
86
Questions :
87
Answers :
90
Questions :
91
The PDF functions in PHP can create PDF files using the PDFlib library
With version 6, PDFlib offers an object-oriented API for PHP 5 in
addition to the function-oriented API for PHP 4. There is also the
Panda module. FPDF is a PHP class which allows to generate PDF files
with pure PHP, that is to say without using the PDFlib library. F from
FPDF stands for Free: you may use it for any kind of usage and modify
it to suit your needs. FPDF requires no extension (except zlib to activate
compression and GD for GIF support) and works with PHP4 and PHP5.
we will need to compile PHP with the GD library of image functions for
this to work. GD and PHP may also require other libraries, depending on
which image formats you want to work with.
Magic methods are the members functions that is available to all the
instance of class Magic methods always starts with "__". Eg.
__construct All magic methods needs to be declared as public To use
magic method they should be defined within the class or program scope
Various Magic Methods used in PHP 5 are: __construct() __destruct()
__set() __get() __call() __toString() __sleep() __wakeup() __isset()
__unset() __autoload() __clone()
Answers :
91
Questions :
92
Answers :
92
Questions :
93
Answers :
93
Questions :
94
Answers :
94
Questions :
95
Answers :
95
Questions :
96
Answers :
96
Using URL rewriting we can convert dynamic URl to static URL Static
URLs are known to be better than Dynamic URLs because of a number
of reasons 1. Static URLs typically Rank better in Search Engines. 2.
Search Engines are known to index the content of dynamic pages a lot
slower compared to static pages. 3. Static URLs are always more
friendlier looking to the End Users. along with this we can use URL
rewriting in adding variables [cookies] to the URL to handle the
sessions.
Questions :
97
Answers :
97
The SQL Server Driver for PHP v1.0 is designed to enable reliable,
scalable integration with SQL Server for PHP applications deployed on
the Windows platform. The Driver for PHP is a PHP 5 extension that
allows the reading and writing of SQL Server data from within PHP
scripts. using MSSQL or ODBC modules we can access Microsoft SQL
server.
echo $e->getMessage();
}
Questions :
98
Answers :
98
Questions :
99
Answers :
99
what is CURL?
Questions :
100
Answers :
100
what is PDO ?
Database provides a systematic and organized way of storing, managing and retri
of logically related information.
Secondly the information has to be persistent, that means even after the applicat
information should be persisted.
Finally it should provide an independent way of accessing data and should not be
application to access the information.
Main difference between a simple file and database that database has independen
accessing information while simple files do not File meets the storing, managing a
a database but not the independent way of accessing data. Many experienced pro
the main difference is that file can not provide multi-user capabilities which a DBM
we look at some old COBOL and C programs where file where the only means of s
see functionalities like locking, multi-user etc provided very efficiently. So its a m
some interviewers think this as a main difference between files and database acce
debate is probably loosing a job.
Questions
What is SQL ?
:2
Questions
What are E-R diagrams?
:5
Answers : In 1969 Dr. E. F. Codd laid down some 12 rules which a DBMS should adhere in orderAnswers
to get the: logo
E-R diagram also termed as Entity-Relationship diagram shows relationship betwe
4
of a true RDBMS.
5
the database. .
Answers : Denormalization is the process of putting one fact in numerous places (its vice-versa of
8
normalization).Only one valid reason exists for denormalizing a relational design - to enhance
performance.The sacrifice to performance is that you increase redundancy in database.
Questions
Can you explain Insert, Update and Delete query?
: 14
Questions
Can you explain Fourth Normal Form and Fifth Normal Form ?
:9
Answers : Insert statement is used to insert new rows in to table. Update to update existing
14
Delete statement to delete a record from the table. Below code snippet for Insert,
:Answers : In fourth normal form it should not contain two or more independent multi-v about an entity and Delete
it
9
should satisfy Third Normal form.
Fifth normal form deals with reconstructing information from smaller pieces of information. TheseINSERT INTO pcdsEmployee SET name='rohit',age='24';
UPDATE pcdsEmployee SET age='25' where name='rohit';
smaller pieces of information can be maintained with less redundancy.
DELETE FROM pcdsEmployee WHERE name = 'sonia';
Questions
Have you heard about sixth normal form?
: 10
Questions
What is order by clause?
: 15
Answers : If we want relational system in conjunction with time we use sixth normal form. At this moment SQL
Answers : ORDER BY clause helps to sort the data in either ascending order to descending o
10
Server does not supports it directly.
15
Ascending order sort query
SELECT name,age FROM pcdsEmployee ORDER BY age ASC
Descending order sort query
Questions
What are DML and DDL statements?
SELECT name FROM pcdsEmployee ORDER BY age DESC
: 11
Answers : DML stands for Data Manipulation Statements. They update data values in table. Below are the most
11
important DDL statements:Questions
What is the SQL " IN " clause?
=>SELECT - gets data from a database table
: 16
=> UPDATE - updates data in a table
Answers : SQL IN operator is used to see if the value exists in a group of values. For instanc
=> DELETE - deletes data from a database table
16
checks if the Name is either 'rohit' or 'Anuradha' SELECT * FROM pcdsEmployee W
=> INSERT INTO - inserts new data into a database table
('Rohit','Anuradha') Also you can specify a not clause with the same. SELECT * FR
WHERE age NOT IN (17,16)
DDL stands for Data definition Language. They change structure of the database objects like table,
index etc. Most important DDL statements are as shown below:=>CREATE TABLE - creates a new table in the database.
=>ALTER TABLE changes table structure in database.
=>DROP TABLE - deletes a table from database
=> CREATE INDEX - creates an index
=> DROP INDEX - deletes an index
Questions
How do we select distinct values from a table?
: 12
Questions
Can you explain the between clause?
: 17
Answers : Below SQL selects employees born between '01/01/1975' AND '01/01/1978' as pe
17
SELECT * FROM pcdsEmployee WHERE DOB BETWEEN '1975-01-01' AND '2011-0
Questions
we have an employee salary table how do we find the second highest from
: 18
Answers : DISTINCT keyword is used to return only distinct values. Below is syntax:- Column age
and Table
Answers
: below Sql Query find the second highest salary
12
pcdsEmp
18
SELECT * FROM pcdsEmployeeSalary a WHERE (2=(SELECT COUNT(DISTINCT(b.s
SELECT DISTINCT age FROM pcdsEmp
pcdsEmployeeSalary b WHERE b.salary>=a.salary))
Questions
What is Like operator for and what are wild cards?
: 13
Questions
What are different types of joins in SQL?
: 19
Answers : LIKE operator is used to match patterns. A "%" sign is used to define the pattern.
13
Below SQL statement will return all words with letter "S"
SELECT * FROM pcdsEmployee WHERE EmpName LIKE 'S%'
Below SQL statement will return all words which end with letter "S"
customer does not have order it will not display that record.
=>>DELETE table can have criteria while TRUNCATE can not.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON Customers.CustomerID =>> TRUNCATE table can not have triggers.
=Orders.CustomerID
Questions
LEFT OUTER JOIN
Whats the difference between UNION and UNION ALL ?
: 25 with or
Left join will display all records in left table of the SQL statement. In SQL below customers
without orders will be displayed. Order data for customers without orders appears as Answers
NULL values.
For SQL syntax is used to select information from two tables. But it selects on
: UNION
example, you want to determine the amount ordered by each customer and you need25
to see whofrom
has both the table. , while UNION ALL selects all records from both the tables.
not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT
OUTER JOIN (Is covered in the next section) if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON Customers.CustomerID
Questions
What are cursors and what are the situations you will use them?
=Orders.CustomerID
: 26
Answers : SQL statements are good for set at a time operation. So it is good at handling set
RIGHT OUTER JOIN
Right join will display all records in right table of the SQL statement. In SQL below all26
orders withare
or scenarios where we want to update row depending on certain criteria. we will
without matching customer records will be displayed. Customer data for orders without customersrows and update data accordingly. Theres where cursors come in to picture.
appears as NULL values. For example, you want to determine if there are any orders in the data with
undefined CustomerID values (say, after a conversion or something like it). You can also see the
RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side Questions
of each table.
What is " Group by " clause?
: 27
SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID
Answers :
Group by clause group similar data so that aggregate values can be derived.
27
Questions
What is CROSS JOIN? or What is Cartesian product?
: 20
Questions
What is the difference between HAVING and WHERE clause?
: 28
Answers : CROSS JOIN or CARTESIAN PRODUCT combines all rows from both tables. Number
of rows will be
20
product of the number of rows in each table. In real life scenario I can not imagine where
we will
want
Answers
: HAVING
clause is used to specify filtering criteria for GROUP BY, while WHERE
to use a Cartesian product. But there are scenarios where we would like permutation 28
and combination
normal SQL.
probably Cartesian would be the easiest way to achieve it.
Questions
How to select the first record in a given set of rows?
: 21
Answers :
Select top 1 * from sales.salesperson
21
Questions
What is the default -SORT order for a SQL?
: 22
Answers :
ASCENDING
22
Questions
What is a self-join?
: 23
Answers :
If we want to join two instances of the same table we can use self-join.
23
Questions
What is a Sub-Query?
: 29
Answers : A query nested inside a SELECT statement is known as a subquery and is an alter
29
join statements. A subquery combines data from multiple tables and returns resul
into the WHERE condition of the main query. A subquery is always enclosed within
returns a column. A subquery can also be referred to as an inner query and the m
outer query. JOIN gives better performance than a subquery when you have to ch
of records.
For example, to retrieve all EmployeeID and CustomerID records from the ORDER
the EmployeeID greater than the average of the EmployeeID field, you can create
shown:
SELECT DISTINCT EmployeeID, CustomerID FROM ORDERS WHERE EmployeeID >
AVG(EmployeeID) FROM ORDERS)
Questions
What are Aggregate and Scalar Functions?
: 30
Answers : Aggregate and Scalar functions are in built function for counting and calculations.
30
Aggregate functions operate against a group of values but returns only one value.
AVG(column) :- Returns the average value of a column
Questions
Whats the difference between DELETE and TRUNCATE ?
COUNT(column) :- Returns the number of rows (without a NULL value) of a colum
: 24
COUNT(*) :- Returns the number of selected rows
Answers : Following are difference between them:
MAX(column) :- Returns the highest value of a column
24
=>>DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table
MIN(column) :- Returns the lowest value of a column
does not log any information but it logs information about deallocation of data page of the table. So
Scalar functions operate against a single value and return value on basis of the sin
TRUNCATE table is faster as compared to delete table.
UCASE(c) :- Converts a field to upper case
finally reside.
Questions What are Fact tables and Dimension Tables ? What is Dimensional Modeli
: 36
Schema Design
Answers : Star schema is good when you do not have big tables in data warehousing. But w
37
becoming really huge it is better to denormalize. When you denormalize star sche
snow flake design. For instance below customeraddress table is been normalized a
table. Same holds true for Salesperson table.
Answers : It is a Form of attack on a database-driven Web site in which the attacker executes unauthorized Customer
SQL
33
commands by taking advantage of insecure code on a system connected to the Internet, bypassing
the firewall. SQL injection attacks are used to steal information from a database from which the data
Questions What is ETL process in Data warehousing? What are the different stages i
would normally not be available and/or to gain access to an organizations host computers through the
: 38
warehousing?
computer that is hosting the database.
SQL injection attacks typically are easy to avoid by ensuring that a system has strongAnswers
input validation.
: ETL (Extraction, Transformation and Loading) are different stages in Data warehou
As name suggest we inject SQL which can be relatively dangerous for the database. Example
38
thisdo
is a
software development we follow different stages like requirement gathering, de
simple SQL
testing. In the similar fashion we have for data warehousing.
SELECT email, passwd, login_id, full_name
Extraction:FROM members WHERE email = 'x'
In this process we extract data from the source. In actual scenarios data source c
Now somebody does not put x as the input but puts x ; DROP TABLE members;.
EXCEL, ACCESS, Delimited text, CSV (Comma Separated Files) etc. So extraction
So the actual SQL which will execute is :complexity of understanding the data source and loading it in a structure of data w
SELECT email, passwd, login_id, full_name FROM members WHERE email = 'x' ; DROP TABLE
Transformation:members;
This process can also be called as cleaning up process. Its not necessary that afte
Think what will happen to your database.
process data is clean and valid. For instance all the financial figures have NULL va
to be ZERO for better analysis. So you can have some kind of stored procedure w
extracted records and sets the value to zero.
Questions
Loading:What is Data Warehousing ?
: 34
After transformation you are ready to load the information in to your final data wa
Questions
What is SQl injection ?
: 33
Answers : Data Warehousing is a process in which the data is stored and accessed from central location and is
34
meant to support some strategic decisions. Data Warehousing is not a requirement for Data mining.
Questions
But just makes your Data mining process more efficient.
What is Data mining ?
: 39
: Data mining is a concept by which we can analyze the current data from differen
Data warehouse is a collection of integrated, subject-oriented databases designed to Answers
support the
39in time. summarize the information in more useful manner. Its mostly used either to deriv
decision-support functions (DSF), where each unit of data is relevant to some moment
information from the existing data or to predict sales to increase customer marke
There are two basic aims of Data mining:-
Questions
What are Data Marts?
: 35
Prediction: Answers : Data Marts are smaller section of Data Warehouses. They help data warehouses collect data. For From the given data we can focus on how the customer or market will perform. Fo
having a sale of 40000 $ per month in India, if the same product is to be sold with
35
example your company has lot of branches which are spanned across the globe. Head-office of the
much
company decides to collect data from all these branches for anticipating market. So to achieve this
IT sales can the company expect.
Summarization:
department can setup data mart in all branch offices and a central data warehouse where all data will
To derive important information to analyze the current business scenario. For exam
report will give a picture to the top management how we are performing on a weekly basis?
Questions
Compare Data mining and Data Warehousing ?
: 40
Questions
What is Object Oriented Programming ?
:1
Answers
Answers : Data Warehousing is technical process where we are making our data centralized while
Data: It is a problem solving technique to develop software systems. It is a technique to
1 or predictterms
40
mining is more of business activity which will analyze how good your business is doing
how of objects. Object maps the software model to real world concept. These ob
and provide services to application or other objects.
it will do in the future coming times using the current data. As said before Data Warehousing is responsibilities
not
a need for Data mining. Its good if you are doing Data mining on a Data Warehouse rather than
on an actual production database. Data Warehousing is essential when we want to consolidate data
Questions
from different sources, so its like a cleaner and matured data which sits in between the
various data
What is a Class ?
:2
sources and brings then in to one format. Data Warehouses are normally physical entities
which are
meant to improve accuracy of Data mining process. For example you have 10 companies
sending
Answers
: A class describes all the attributes of objects, as well as the methods that implem
data in different format, so you create one physical database for consolidating all the2data from member objects. It is a comprehensive data type which represents a blue print of
different company sources, while Data mining can be a physical model or logical model. You cantemplate of object.
create a database in Data mining which gives you reports of net sales for this year for all
companies. This need not be a physical database as such but a simple query.
Questions
What are indexes? What are B-Trees?
: 41
Questions
What is an Object ?
:3
Answers : It is a basic unit of a system. An object is an entity that has attributes, behavior, a
3
are members of a class. Attributes and behavior of an object are defined by the cl
Answers : Index makes your search faster. So defining indexes to your database will make your search
41
faster.Most of the indexing fundamentals use B-Tree or Balanced-Tree principle. Its not a principle
that is something is created by SQL Server or ORACLE but is a mathematical derived Questions
fundamental.In
What is the relation between Classes and Objects?
order that B-tree fundamental work properly both of the sides should be balanced. : 4
Answers : They look very much same but are not same. Class is a definition, while object is
Questions I have a table which has lot of inserts, is it a good database design to create4indexes oncreated. Class is a blue print while objects are actual objects existing in real world
class CAR which has attributes and methods like Speed, Brakes, Type of Car etc.C
: 42
that table?
prototype, now we can create real time objects which can be used to provide func
Inserts are slower on tables which have indexes, justify it?or Why do page splitting
we can create a Maruti car object with 100 km speed and urgent brakes.
happen?
Answers : All indexing fundamentals in database use B-tree fundamental. Now whenever there is new data
42
inserted or deleted the tree tries to become unbalance.
Questions
What are different properties provided by Object-oriented systems ?
Creates a new page to balance the tree.
:5
Shuffle and move the data to pages.
Answers
So if your table is having heavy inserts that means its transactional, then you can visualize
the: Following are characteristics of Object Oriented Systems:5 the end-user
Abstraction
amount of splits it will be doing. This will not only increase insert time but will also upset
It allows
complex real world to be represented in simplified manner. Example colo
who is sitting on the screen. So when you forecast that a table has lot of inserts its not a good idea
to
RGB.By just making the combination of these three colors we can achieve any col
create indexes.
model of real world or concept.
Encapsulation
Questions What are the two types of indexes and explain them in detail? or Whats the difference The process of hiding all the internal details of an object from the outside world.
Communication
: 43
between clustered and non-clustered indexes?
Using messages when application wants to achieve certain task it can only be don
Answers : There are basically two types of indexes:of objects. A single object can not do the entire task. Example if we want to make
43
Clustered Indexes.
form. We will use Customer object, Order object, Product object and Payment obj
Non-Clustered Indexes.
functionality. In short these objects should communicate with each other. This is a
In clustered index the non-leaf level actually points to the actual data.In Non-Clustered index theobjects
leaf
send messages to each other.
nodes point to pointers (they are rowids) which then point to actual data.
Object lifetime
All objects have life time. Objects are created, initialized, necessary functionalities
the object is destroyed. Every object have there own state and identity, which diff
instance.
Questions
What is an Abstract class ?
:6
Answers : Abstract class defines an abstract concept which can not be instantiated and comparing o interface
// it
array of name objects
6
can have some implementation while interfaces can not. Below are some
clsName personArray[] = {new clsName(), new clsName(), new clsName()};
points for abstract class:}
=>We can not create object of abstract class it can only be inherited in a below class.
Normally inner classes are used for data structures like one shown above or some
=> Normally abstract classes have base implementation and then child classes derive from the classes.
abstract class to make the class concrete.
Questions
What are Abstract methods?
:7
Questions
What is a constructor in class?
: 11
Answers : Constructor has the same name as the class in which it resides and looks from sy
Answers : Abstract class can contain abstract methods. Abstract methods do not have implementation.
11
Abstract
looks similiar to a method. Constructor is automatically called immediately after th
7
methods should be implemented in the subclasses which inherit them. So if an abstract class has before
an
the new operator completes. Constructors have no return type, not even v
abstract method class inheriting the abstract class should implement the method or else java compiler
the implicit return type of a class' constructor is the class type itself. It is the cons
will through an error. In this way, an abstract class can define a complete programming interface initialize the internal state of an object so that the code creating an instance will h
thereby providing its subclasses with the method declarations for all of the methods necessary to initialized, usable object immediately.
implement that programming interface. Abstract methods are defined using "abstract" keyword. Below
is a sample code snippet.
Questions
abstract class pcdsGraphics
Can constructors be parameterized?
: 12
{
abstract void draw();
Answers : Yes we can have parameterized constructor which can also be termed as construc
}
12
Below is a code snippet which shows two constructors for pcdsMaths class one wit
Any class inheriting from "pcdsGraphics" class should implement the "draw" method or else the java
one with out.
compiler will throw an error. so if we do not implement a abstract method the program will not class pcdsMaths
compile.
{
Questions
What is the difference between Abstract classes and Interfaces ?
:8
double PI;
// This is the constructor for the maths constant class.
pcdsMaths()
{PI = 3.14;}
pcdsMaths(int pi)
{
PI = pi;
}}
bootstrap class loader. Its primary responsibility is to load classes from the extension directories,
normally located the jre/lib/ext directory. This provides the ability to simply drop in new extensions,
such as various security extensions, without requiring modification to the user's class path.
System Class loader
The system class loader also termed application class loader is the class loader responsible for loading
code from the path specified by the CLASSPATH environment variable. It is also used to load an
applications entry point class that is the "static void main ()" method in a class.
'
Questions
how to do login in mysql with unix shell
:1
Questions
whats the main difference between ArrayList / HashMap and Vector / Hashtable?
Answers : By below method if password is pass and user name is root
: 15
1
# [mysql dir]/bin/mysql -h hostname -u root -p pass
Answers : Vector / HashTable are synchronized which means they are thread safe. Cost of thread safe is
15
performance degradation. So if you are sure that you are not dealing with huge number of threads
then you should use ArrayList / HashMap.But yes you can still
Questions
how you will Create a database on the mysql server with unix shell
synchronize List and Maps using Collections provided methods ::2
List OurList = Collections.synchronizedList (OurList);
Answers :
Map OurMap = Collections.synchronizedMap (OurMap);
mysql> create database databasename;
2
Questions
What are access modifiers?
: 16
Questions
how to list or view all databases from the mysql server.
:3
Answers : Access modifiers decide whether a method or a data variable can be accessed by another method in
Answers :
16
another class or subclass.
mysql> show databases;
3
four types of access modifiers:
Public: - Can be accessed by any other class anywhere.
Protected: - Can be accessed by classes inside the package or by subclasses ( that means classes
Questions
who inherit from this class).
How Switch (select or use) to a database.
: 4 package do
Private - Can be accessed only within the class. Even methods in subclasses in the same
not have access.
Answers :
mysql> use databasename;
Default - (Its private access by default) accessible to classes in the same package but
4 not by classes
in other packages, even if these are subclasses.
Questions
Define exceptions ?
: 17
Questions
How To see all the tables from a database of mysql server.
:5
Answers :
show tables;
Answers : An exception is an abnormal condition that arises in a code sequence at run time. Basically
there mysql>
are
5
17
four important keywords which form the main pillars of exception handling: try, catch, throw and
finally. Code which you want to monitor for exception is contained in the try block. If any exception
occurs in the try block its sent to the catch block which can handle this error in a more
rational
Questions
How to see table's field formats or description of table .
manner. To throw an exception manually you need to call use the throw keyword. If you
: 6 want to put
any clean up code use the finally block. The finally block is executed irrespective if there is an error or
Answers :
not.
mysql> describe tablename;
6
Questions
What is serialization?How do we implement serialization actually?
: 18
Questions
How to delete a database from mysql server.
:7
Answers : Serialization is a process by which an object instance is converted in to stream of bytes. There are
Answers
:
18
many useful stuff you can do when the object instance is converted in to stream of bytes
for instance
mysql> drop database databasename;
7
you can save the object in hard disk or send it across the network.
In order to implement serialization we need to use two classes from java.io package
Questions
ObjectOutputStream and ObjectInputStream. ObjectOutputStream has a method called writeObject,
How we get Sum of column
:8
while ObjectInputStream has a method called readObject. Using writeobject we can write and
Answers
:
readObject can be used to read the object from the stream. Below are two code snippet
which used
mysql> SELECT SUM(*) FROM [table name];
8
the FileInputStream and FileOutputstream to read and write from harddisk.
Questions
How to delete a table
:9
Questions
How you will Show unique records.
: 17
Answers :
mysql> drop table tablename;
9
Answer :
17
Questions
How you will Show all data from a table.
: 10
Answers :
mysql> SELECT * FROM tablename;
10
Answer :
18
Questions How to returns the columns and column information pertaining to the
: 11
designated table
Answers :
mysql> show columns from tablename;
11
Questions
How to Show certain selected rows with the value "pcds"
: 12
Answers :
mysql> SELECT * FROM tablename WHERE fieldname = "pcds";
12
Questions How will Show all records containing the name "sonia" AND the phone
: 13
number '9876543210'
Answers : mysql> SELECT * FROM tablename WHERE name = "sonia" AND phone_number =
13
'9876543210';
Questions How you will Show all records not containing the name "sonia" AND the
: 14
phone number '9876543210' order by the phone_number field.
Answer :
14
Questions
how to Return total number of rows.
: 19
Answers :
mysql> SELECT COUNT(*) FROM tablename;
19
Questions
How to Join tables on common columns.
: 20
Answer :
20
Questions How to Creating a new user. Login as root. Switch to the MySQL db. Make
: 21
user. Update privs.
Answer :
21
# mysql -u root -p
mysql> use mysql;
Questions How to Show all records starting with the letters 'sonia' AND the phone
: 15
number '9876543210'
Answers : mysql> SELECT * FROM tablename WHERE name like "sonia%" AND phone_number Questions
How to Change a users password from unix shell.
15
= '9876543210';
: 22
Questions How to show all records starting with the letters 'sonia' AND the phone
: 16
number '9876543210' limit to records 1 through 5.
Answers : mysql> SELECT * FROM tablename WHERE name like "sonia%" AND phone_number Questions How to Change a users password from MySQL prompt. Login as root. Set
16
= '9876543210' limit 1,5;
: 23
password. Update privs.
Questions Use a regular expression to find records. Use "REGEXP BINARY" to force
: 16
case-sensitivity. This finds any record beginning with r.
Answer :
16
Answer :
23
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Questions How to Recover a MySQL root password. Stop the MySQL server process.
Questions
: 24
Start again with no grant tables. Login to MySQL as root. Set new password.: 30
Exit MySQL and restart MySQL server.
Answer :
Answer : # /etc/init.d/mysql stop
30
24
# mysqld_safe --skip-grant-tables &
# mysql -u root
Questions
mysql> use mysql;
: 31
mysql> update user set password=PASSWORD("newrootpassword") where
User='root';
Answer :
mysql> flush privileges;
31
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Questions
: 32
Questions
How to Set a root password if there is on root password.
: 25
Answer :
25
Questions
How to Update a root password.
: 26
Answer :
26
Answer :
32
Questions
How to make a column bigger and Delete unique from table.
: 33
Answer :
33
Questions How to allow the user "sonia" to connect to the server from localhost using
: 27
the password "passwd". Login as root. Switch to the MySQL db. Give privs. Answer :
34
Update privs.
Answers : # mysql -u root -p
27
mysql> use mysql;
mysql> grant usage on *.* to sonia@localhost identified by 'passwd';
mysql> flush privileges;
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name]
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Questions How to dump all databases for backup. Backup file is sql commands to
: 35
recreate all db's.
Answer :
35
Questions How to give user privilages for a db. Login as root. Switch to the MySQL db.
: 28
Grant privs. Update privs.
Questions
Answers : # mysql -u root -p
: 36
28
mysql> use mysql;
Answer :
mysql> INSERT INTO user
(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv)36
VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
Questions
or
: 37
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
Answer :
37
Questions
How To update info already in a table and Delete a row(s) from a table.
: 29
Answer :
29
Questions
Restore database (or database table) from backup.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = : 38
'Y' where [field name] = 'user';
Answer : # [mysql dir]/bin/mysql -u username -ppassword databasename <
mysql> DELETE from [table name] where [field name] = 'whatever';
38
/tmp/databasename.sql
Questions
How to Create Table show Example
: 39
Answer :
39
Questions
: 40
Answers :
40
> If the method is get -, the user agent takes the value of action,
How to search second maximum(second highest) salary value(integer)from appends a ? to it, then appends the form data set, encoded using the
table employee (field salary)in the manner so that mysql gets less load?
application/x-www-form-urlencoded content type. The user agent then
By below query we will get second maximum(second highest) salary
traverses the link to this URI. In this scenario, form data are restricted to
value(integer)from table employee (field salary)in the manner so that mysql gets less
ASCII codes.
load?
SELECT DISTINCT(salary) FROM employee order by salary desc limit 1 , 1 ; > If the method is post , the user agent conducts an HTTP post
(This way we will able to find out 3rd highest , 4th highest salary so on just need to
transaction using the value of the action attribute and a message created
change limit condtion like LIMIT 2,1 for 3rd highest and LIMIT 3,1 for 4th
some one may finding this way useing below query that taken more time as compareaccording to the content type specified by the enctype
to above query SELECT salary FROM employee where salary < (select max(salary)
attribute.
from employe) order by salary DESC limit 1 ;
Question : What are the differences between Get and post methods in
form submitting. Give the case where we can use get and we can use
post methods?
Answer : When to use GET or POST
The HTML 2.0 specification says, in section Form Submission (and the
HTML 4.0 specification repeats this with minor stylistic changes):
>If the processing of a form is idempotent (i.e. it has no lasting
observable effect on the state of the
world), then the form method should be GET. Many database searches
have no visible side-effects and make ideal applications of query forms.
>If the service associated with the processing of a form has side effects
Firstly, the the HTTP protocol specifies differing usages for the two
methods. GET requests should always be idempotent on the server. This
means that whereas one GET request might (rarely) change some state on
the Server, two or more identical requests will have no further effect.
This is a theoretical point which is also good advice in practice. If a user
hits reload on his/her browser, an identical request will be sent to the
server, potentially resulting in two identical database or guestbook entries,
counter increments, etc. Browsers may reload a GET URL automatically,
particularly if cacheing is disabled (as is usually the case with CGI
output), but will typically prompt the user before re-submitting a POST
request. This means youre far less likely to get inadvertently-repeated
entries from POST.
GET is (in theory) the preferred method for idempotent operations, such
as querying a database, though it matters little if youre using a form.
There is a further practical constraint that many systems have built-in
limits to the length of a GET request they can handle: when the total size
of a request (URL+params) approaches or exceeds 1Kb, you are welladvised to use POST in any
case.
I would prefer POST when I dont want the status to be change when user
resubmits. And GET
when it does not matter.
can only access the data by the field names, and not by their offsets
(numbers are illegal property names).
Question : What is the difference between $message and $$message?
Question : Who is the father of PHP and explain the changes in PHP
versions?
Answer : Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an
early and no longer supported version of PHP. PHP 3 is the successor to
PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP,
which uses the Zend engine under the hood. PHP 5 uses Zend engine 2
which, among other things, offers many additional OOPs features.
Question : How can we submit a form without a submit button?
Answer : The main idea behind this is to use Java script submit()
function in order to submit the form without explicitly clicking any
submit button. You can attach the document.formname.submit() method
to onclick, onchange events of different inputs and perform the form
submission. you
can even built a timer function where you can automatically submit the
form after xx seconds once the loading is done (can be seen in online test
sites).
Question : In how many ways we can retrieve the data in the result
set of
MySQL using PHP?
Answer : You can do it by 4 Ways
1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc
Question : What is the difference between mysql_fetch_object and
mysql_fetch_array?
Answer : mysql_fetch_object() is similar to mysql_fetch_array(), with
one difference an object is returned, instead of an array. Indirectly, that means that you
Answer : Yes we can use include() more than one time in any page
though it is not a very good practice.
Question : What are the different tables present in MySQL, which
type of table is generated when we are creating a table in the
following syntax:
create table employee (eno int(2),ename varchar(10)) ?
Answer : Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23 and as a result
if
we do not specify the table name explicitly it will be assigned to the
default engine.
Question : Functions in IMAP, POP3 AND LDAP?
Answer : The Zend Engine is the internal compiler and runtime engine
used by PHP4. Developed by Zeev Suraski and Andi Gutmans, the Zend
Engine is an
abbreviation of their names. In the early days of PHP4, it worked as
follows:
The PHP script was loaded by the Zend Engine and compiled into Zend
opcode. Opcodes, short for operation codes, are low level binary
instructions. Then the opcode was executed and the HTML generated sent
to the client. The opcode was flushed from memory after
execution.Today, there are a multitude of products and techniques to help
you speed up this process. In the following diagram, we show the how
modern PHP scripts work; all the shaded boxes are optional.
Answer : All of those are open source resource. Security of Linux is very
very more than windows. Apache is a better server that IIS both in
functionality and security. MySQL is world most popular open source
database. PHP is more faster that asp or any other scripting language.
Question : How can we encrypt and decrypt a data present in a
MySQL table using MySQL?
Answer : AES_ENCRYPT () and AES_DECRYPT ()
Question : How can we encrypt the username and password using
PHP?
Answer : The functions in this section perform encryption and
decryption, and
compression and uncompression:
Encryption
Decryption
AES_ENCRYT() AES_DECRYPT()
PHP Scripts are loaded into memory and compiled into Zend opcodes.
Question : What are the current versions of apache, PHP, and
MySQL?
Answer : As of Aug 2008 the current versions are PHP: php5.2.6
MySQL: MySQL 5.1.2
ENCODE()
DECODE()
DES_ENCRYPT(
DES_DECRYPT()
)
ENCRYPT()
Not available
MD5()
Not available
OLD_PASSWOR
Not available
D()
PASSWORD()
Not available
SHA() or
SHA1()
Not available
Not available
UNCOMPRESSED_LEN
GTH()
on which the instructions operates on) are kept separate. Multiple sets of
code can access and modify one set of data. One set of code may rely on
data in multiple places. Multiple sets of code and data are required to
work together. Changes made to any of the code sets and data sets can
cause problems through out the system.Object-Oriented programming
takes a radically different approach:Code and data are merged into one
indivisible item an object (the term component has also been used to
describe an object.) An object is an abstraction of a set of real-world
things (for example, an object may be created around date) The object
would contain all information and
functionality for that thing (A date object it may contain labels like
January, February, Tuesday, Wednesday.
It may contain functionality that manages leap years, determines if it is a
business day or a holiday, etc., See Fig. 1). Ideally, information about a
particular thing should reside in only one place in a system.The
information within an object is encapsulated (or hidden) from the rest of
the system. A system is composed of multiple objects (i.e., date function,
reports, order processing, etc., See Fig 2). When one object needs
information from another object, a request is sent asking for specific
information. (for example, a report object may need to know what todays
date is and will send a request to the date object) These requests are called
messages and each object has an interface that manages messages. OO
programming languages include features such as class, instance,
inheritance, and polymorphism that increase the power and
flexibility of an object.
Question : What is the use of friend function?
Answer : Sometimes a function is best shared among a number of
different classes. Such functions can be declared either as member
functions of one class or as global functions. In either case they can be set
to be friends of other classes, by using a friend specifier in the class that
is admitting them. Such functions can use all attributes of the class which
names them as a friend, as if they were themselves members of that class.
A friend declaration is essentially a prototype for a member function, but
instead of requiring an implementation with the name of that class
attached by the double colon syntax, a global function or member
function of another class provides the match.
Question : What are the differences between public, private,
protected,static, transient, final and volatile?
Answer : PHP 3 is most procedure oriented and , PHP4 and PHP5 aer
object oriented. For more details
http://php.net/
Question : How can we convert asp pages to PHP pages?
Answer : There are lots of tools available for asp to PHP conversion. you
can search Google for that. the best one is available at
http://asp2php.naken.cc/
Question : What is the functionality of the function htmlentities?
Answer : Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with
htmlentities(), all characters which have HTML character entity
equivalents are translated into these entities.
Question : How can we get second of the current time using date
function?
Answer : $second = date(s);
Question : How can we convert the time zones using PHP?
Answer : By using date_default_timezone_get and
date_default_timezone_set function on PHP 5.1.0
<!p// Discover what 8am in Tokyo relates to on the East Coast of the US
// Set the default timezone to Tokyo time:
date_default_timezone_set(Asia/Tokyo);
// Now generate the timestamp for that particular timezone, on Jan 1st,
2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);
// Now set the timezone back to US/Eastern
date_default_timezone_set(US/Eastern);
// Output the date in a standard format (RFC1123), this will print:
// Fri, 31 Dec 1999 18:00:00 EST
echo
, date(DATE_RFC1123, $stamp) ,
Answer : By default the maximum size is 2MB. and we can change the
following setup at php.iniupload_max_filesize = 2M
; ?>
Question : How can we increase the execution time of a PHP script?
Question : What is meant by urlencode and urldecode?
Answer : URLencode returns a string in which all non-alphanumeric
characters except -_. have been replaced with a percent (%) sign followed
by two hex digits and spaces encoded as plus (+) signs. It is encoded the
same way that the posted data from a WWW form
is encoded, that is the same way as in application/x-www-formurlencoded media type. urldecode decodes any %## encoding in the given
string.
Question : What is the difference between the functions unlink and
unset?
Answer : unlink() deletes the given file from the file system.
unset() makes a variable undefined.
Question : How can we register the variables into a session?
Question : What is the PHP predefined variable that tells the What
types of
images that PHP supports?
Answer : Though i am not sure if this is wrong or not, With the exif
extension you are able to work with image meta data.
Question : How can I know that a variable is a number or not using a
JavaScript?
Answer : bool is_numeric ( mixed var) Returns TRUE if var is a number
or a numeric string, FALSE otherwise.or use isNaN(mixed var)The
isNaN() function is used to check if a value is not a number.
Question : List out some tools through which we can draw E-R
diagrams for mysql.
Answer :
Case Studio
Smart Draw
Question : How can I retrieve values from one database server and
store themin other database server using PHP?
Answer : WeWe can always fetch from one database and rewrite to
another. Here is a nice solution of it.
$db1 = mysql_connect(host,user,pwd);
mysql_select_db(db1?, $db1);
$res1 = mysql_query(query,$db1);
$db2 = mysql_connect(host,user,pwd);
mysql_select_db(db2?, $db2);
$res2 = mysql_query(query,$db2);
At this point you can only fetch records from you previous ResultSet, i.e
$res1 But you cannot execute new query in $db1, even if yousupply the
link as because the link was overwritten by the new db.so at this point the
following script will fail
$res3 = mysql_query(query,$db1); //this will failSo how to solve that?
take a look below.
$db1 = mysql_connect(host,user,pwd);
mysql_select_db(db1?, $db1);
$res1 = mysql_query(query,$db1);
file stores the table definition.The data file has a .MYD (MYData)
extension.The index file has a .MYI (MYIndex) extension.
Answer : The following table describes the maximum length for each
type of identifier.
Identifi Maximum
er
Length(bytes)
Databa
64
se
Table
64
Column 64
Index 64
Alias
255
There are some restrictions on the characters that may appear
in identifiers.
Question : How many values can the SET function of MySQL take?
Answer : MySQL set can take zero or more values but at the maximum it
can take 64 values.
Question : What are the other commands to know the structure of
table using MySQL commands except explain command?
Answer : describe Table-Name;
Question : How many tables will create when we create table, what
are they?
Answer : The .frm file stores the table definition.The data file has a
.MYD (MYData) extension.The index file has a .MYI (MYIndex)
extension.
Question : What is the purpose of the following files having
extensions 1) .frm2) .myd 3) .myi? What do these files contain?
Answer : In MySql, the default table type is MyISAM.Each MyISAM
table is stored on disk in three files. The files have names that begin with
the table name and have an extension to indicate the file type.The .frm
Answer :
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo $num_rows rows found;
Question : How many ways we can we find the current date using
MySQL?
Answer :
SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use SELECT CURTIME();
CURRENT_TIME() = CURTIME()
Answer : Both of them are open source software (so free of cost),
supportcross platform. php is faster then ASP and JSP.
Type
Nul Ke Defaul
Extra
l
y t
user_pri_i
int(15)
d
userid
varchar(1
YES
0)
PRI null
auto_increme
nt
null
the value of user_pri_id the last row 999 then What will happen inthe
following conditions?Condition1: Delete all the rows and insert
another row then.What is the starting value for this auto incremented
field user_pri_id ,Condition2: Delete the last row(having the field
value 999) andinsert another row then. What is the value for this auto
incremented field user_pri_id.
Answer : In both cases let the value for auto increment field be n then
nextrow will have value n+1 i.e. 1000.
Whats PHP ?
difference between PHP4 and PHP5?
What Is a Session?
How can we register the variables into a session?
What is meant by PEAR in php?
6.
7.
8.
9.
10.
36.
37.
38.
39.
40.