Tuesday, February 2, 2016

LocalHost PhpMyAdmin

login.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>

<body>
<form method="post" action="">
<input type="text" name="login" placeholder="Enter UserName"><br/>
<input type="password" name="pass" placeholder="Enter Password"><br/>
<input type="submit" name="submit" value="Log In">
</form>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("SELECT * FROM user WHERE login='$login' AND password='$pass'");
if($result->num_rows>0)
{
echo "<h1>Login Successful</h1>";
}
else
{
echo "<h1> Not Registered</h1>";
}
}
?>
</body>
</html>
_________________________________________________
entry_procedure.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Entry Procedure</title>
</head>
<body>
<form method="post" action="">
<input type="text" name="name" placeholder="Enter Name"><br/>
<input type="text" name="address" placeholder="Enter Address"><br/>
<input type="text" name="mobile" placeholder="Enter Mobile"><br/>
<input type="submit" name="submit" value="INSERT">
</form>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("CALL InsertStudent('$name', '$address', '$mobile')");
if($mysqli->affected_rows>0)
{
header("Location:display_data.php");
}
else
{
echo "<h1 align='center' style='color:red'>Not Inserted</h1>";
}
}
?>
</body>
</html>
________________________________________
edit.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Edit Page</title>
</head>
<body>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
$id=$_GET['id'];
$result=$mysqli->query("SELECT * FROM student WHERE id='$id'");
$data=$result->fetch_array();
?>
<form method="post" action="">
<input type="text" name="name" value="<?php echo $data['name'] ?>"><br/>
<input type="text" name="address" value="<?php echo $data['address'] ?>"><br/>
<input type="text" name="mobile" value="<?php echo $data['mobile'] ?>"><br/>
<input type="submit" name="submit" value="Update">
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("UPDATE student SET name='$name', address='$address', mobile='$mobile' WHERE id='$id'");
if($mysqli->affected_rows>0)
{
header("Location:display_data.php");
}
else
{
echo "<h1 align='center' style='color:red'>Not Update</h1>";
}
}
?>
</body>
</html>
------------------------------------------------------------------------------------------------
display_data.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Display</title>
</head>
<body>
<form method="post" action="">
<table align="center" border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Mobile</th>
<th>Module Name</th>
<th>Total Marks</th>
<th>Edit</th>
</tr>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
$result=$mysqli->query("SELECT * FROM display_view");
while($data=$result->fetch_array()){
?>
<tr>
<td><?php echo $data['id'] ?></td>
<td><?php echo $data['name'] ?></td>
<td><?php echo $data['address'] ?></td>
<td><?php echo $data['mobile'] ?></td>
<td align="center"><?php echo $data['module_name'] ?></td>
<td align="center"><?php echo $data['totalmarks'] ?></td>
<td align="center"><a href="edit.php?id=<?php echo $data['id'] ?>">Edit</a></td>
</tr>
<?php }?>
</table>
</form>

</body>
</html>
__________________________
delete.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Delete</title>
</head>

<body>
<form method="post" action="">
<select name="deleteid">
<?php $mysqli=new MySQLi('localhost','root','','idb_bisew');
$sql=$mysqli->query("SELECT * FROM student");
while($data=$sql->fetch_array()){
?>
<option value="<?php echo $data['id'] ?>"><?php echo $data['id'] ?>-<?php echo $data['name'] ?></option>
<?php } ?>
</select>
<br/>
<input type="submit" name="submit" value="Delete">
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
$id=$_POST['deleteid'];
$result=$mysqli->query("DELETE FROM student WHERE id='$id'");
if($mysqli->affected_rows>0)
{
echo "<h1 align='center' style='color:green'>Id-$id Delete Successful</h1>";
}
else
{
echo "<h1 align='center' style='color:red'>Not Delete</h1>";
}
}
?>
</body>
</html>
___________________
display_view
CREATE VIEW display AS
SELECT student.id, name, address, mobile, module_name, totalmarks
FROM student, result
WHERE student.id=result.student_id ;
_________________
INSERT_PROCEDURE
DELIMITER $$
CREATE PROCEDURE InsertStudent(IN st_name VARCHAR(50), IN st_address VARCHAR(100), IN st_mobile VARCHAR(20))
BEGIN
INSERT INTO student SET name=st_name, address=st_address, mobile=st_mobile ;
END $$
DELIMITER ;
__________
DELIMITER $$
CREATE TRIGGER resultdelete
AFTER DELETE ON student
FOR EACH ROW
BEGIN
DELETE FROM result
WHERE student_id=OLD.id;
END $$
DELIMITER ;


Saturday, January 30, 2016

MysQL ALL

  1. How many ways session handling can be done?
Answer: Session handling can be handled with the following:
1. Use of cookies : the practice of storing bits of information on the client's machine.
2. Use of session ID(SID) : Assigning each site visitor a unique identifying attribute.
  1. What do you mean by directory service?
Answer: Directory Service: It offers system administrators, developers, and end users alike a consistent, efficient, and secure means for viewing and managing resources such as people, fles, printers, and applications.
  1. Briefly describe the following Engines:
  1. MyISAM
  2. InnoDB.
Answer:
MyISAM:
  1. MyISAM become MYSQL's default storage engine as of version 3.23.
  2. MyISAM tables are operating system independent.
  3. Capable of sorting more data, but at a cost of less storage space than counterpart.
  4. Three MyISAM formats: static, dynamic, and compress are available.
InnoDB:
    1. Robust transactional storage engine
    2. Working with large data stores.
It has been available to MySQL users since version 3.23 and effective solution for transactional applications.
  1. How does the session data store in computer?
Answer: Session data can be stored in four ways:
    1. Within flat failes (files),
    2. Within volatile memory (mm),
    3. Using the SQLite database (sqlite), or
Through user-defined functions (user).
  1. Classify the MySQL datatypes.
Answer: MySQL broken down datatypes in three broad categories:
a) Date and time  b) Numeric data types  c) String data types
a) Data types in Date and time category:
  1. DATE
  2. DATETIME
  3. TIME
  4. TIMESTAMP
  5. YEAR
b) Data types in Numeric category:
  1. BOOL, BOOLEAN
  2. BIGINT
  3. INT
  4. MEDIUMINT
  5. SMALLINT
  6. TINYINT
  7. DECIMAL
  8. DOUBLE
  9. FLOAT ([M,D])
  10. FLOAT (precision)
c) Data types in String category:
    1. CHAR
    2. VARCHAR
    3. LONGBLOB
    4. LONGTEXT
    5. MEDIUMBLOB
    6. MEDIUMTEXT
    7. BLOB
    8. TEXT
    9. TINYBLOB
    10. TINYTEXT
    11. ENUM
    12. SET

  1. Name all the MySQL data type attributes.
Answer: MySQL supported data type attributes are:
1. AUTO_INCREMENT
2. BINARY
3. DEFAULT
4. INDEX
5. NATIONAL
6. NOT NULL
7. NULL
8. PRIMARY KEY
9. UNIQUE
10. ZEROFIL

  1. Write the examples for the following mysql commands on the table.
a) SHOW b) CREATE c) INSERT d) UPDATE e) SELECT f) ALTER g) DESC h) DESCRIBE i) DROP
j) DELETE


Answer:
a) example:
mysql> show tables;

b) example:
mysql>create table book(
id int(10) not null auto_increment primary key,
title varchar(50) not null,
author varchar(50)
);

c) example:
mysql>insert into book(title,author)values('MySQL','Mikel Jone');

d) example:
mysql>update book set title='Advanced MySQL' where id=1;

e) example:
mysql>select id, title, author from book;

f) example:
mysql>alter table book add column isbn varchar(20);

g) example:
mysql>desc book;

h) example:
mysql>describe book;

i) example:
mysql>drop table book;

j) mysql>delete from book where id=3;



IDB-BISEW IT Scholarship Project
WPSI Round -26
Student Name: ID:

  1. What statement is/are false for web services?
A. used to work on single machine
B. write once and reuse anywhere
C. it is a software
D. all  

  1. To get particular node value which method of simpleXML is used?
A. asXML()                        B. children()
C. xpath()                          D. attribute()

  1. Which of the following storage engine is operating system independent?
A. InnoDB                              B. EXAMPLE
C. MyISAM                            D. MEMORY

  1. Which storage engine does not support VARCHAR dayatype?
A. InnoDB                              B. FEDERATED
C. MyISAM                            D. MEMORY

  1. Which of the following is the MySQL’s third largest integer datatype?
A. INT                                  B. SMALLINT
C. TINYINT                         D. none

  1. Which of the following commands should be used to create a database named “company”?
A.CREATE DATABASE company
B. CREATE –I company
C. DATABASE / company
D. mysql –s company

  1. Internally information is held in tables. Which of these is NOT a valid format:
A. InnoDb         B. MyIsam
C. Isam              D. Isam99

  1. Which of the following can add a row to a table?
A.  Commit    B.  Add
C.  Alter          D. Insert

  1. Which of the following encryption package perform two-way encryption?
A. MD5     B. mhash       C. MCrypt          D. all

  1. In which of the follwing SQL statements is the keyword SET used?
a. UPDATE  b. DELETE
c. SELECT   d. APPEND

  1. SQLite is a –
A. server        B. file      C. table     D. none

  1. To manage data into MySQL server which mechanism is/are used?
A. Query                              B. table handler  
C. Storage Engine              D. all


  1. Which of the following feature is called MySQL’s one of the greatest speed enhancements?
A. security                           B. Replication
C. Query Caching               D.  Indexing

  1. Which SQL statement is used to insert a new data in a database?
a) INSERT INTO  b) UPDATE
c) ADD                  d) INSERT NEW

  1. You use the _____ clause to list data in a specific order.

A.GROUP BY            B. SORT BY
C.ORDER BY            D. HAVING

  1. What happens if you run a DELETE command that does not contain a WHERE clause?

A. Single row will be deleted
B. First row will be deleted
C. Last row will be deleted
D. All rows will be deleted from the table.

  1. Which of the following commands lists all the privileges granted to a user?

A. SHOW PRIVILEGES  B. SHOW GRANTS
B. SHOW REVOKE          C. NONE

  1. The database administrator uses the _____ command to revoke privileges from users.

A. REVOKE         B. GRANT
C. COMMIT        D. ROLLBACK

  1. Which mysql function is used to select database and execute query at a time?
A. mysql_select_db()             B. mysql_query()
C. mysql_db_query()              D. mysql_result()

  1. Which of the mysql function(s) return array?
A. mysql_fetch_row()       B. mysql_fetch_array()
C. mysql_fetch_assoc()           D. all  


  1. A SELECT command without a WHERE clause returns?
a) All the records from a table that match the previous WHERE clause
b) All the records from a table, or information about all the records
c) SELECT is invalid without a WHERE clause
d) Nothing

  1. You are required to buy a license for MySQL if
A. You are never required to buy a license
B. You incorporate it into a product that you sell
C. You use MySQL in a live application and not just for evaluation
D. You use it on a publicly accessible site

  1. Automatic crash recovery is available in which storage engine?
A. InnoDB                              B. FEDERATED
C. MyISAM                            D. MEMORY

  1. Which of the following is/are example(s) of third-party client program of php?
A. MySQL Query Explorer   B. MySQL Administrator
C. PHPMyAdmin                    D. Netscape

  1. If the default width of an unsigned INT is 5 then ZEROFILL INT value of 5 will be represented as –
A. 5         B. 50000       C. 00005             D. none

  1. To invalidate the current session completely which session function is used?
A. session_unset()              B. session_reset()

C. session_destroy()          D. all
IDB-BISEW IT Scholarship Project
WPSI Round -26
Student Name: ID:

  1. To replace the file from temporary location to server which function is used?
A. is_upload_file()          B. move_upload_file()
C. copy()                           D. none

  1. MySQL configuration can be changed by which file?
A. php.ini                           B. mysql.ini
C. my.ini                            D. my.cnf


  1. What is the maximum year range of the TIMESTAMP according to MySQL manual?
A. 2020                                B. 1970
C. 2030                                 D. 2037

  1. Which of the privilege type column-level GRANT does not support?
A. Select                               B. Insert
C. Update                             D. Delete

  1. Access privileges can be specified at which levels in MySQL?
    A. Login, Database, Table Row and Column
    B. Login, Database, Table and Column
    C. Login and Database
    D. Login Only

  1. MySQL is
A. A GUI (Graphic User Interface)
B. A Relational Database Management System
C. An API (Application Programmer Interface)
D. A technique for writing reliable programs


  1. After creating the “company" database, you want to use it. Which command should you give?
A.SELECT company B.ENTER company
C.USE company      D.OPEN company

  1. In MySQL, use the ____ data type for variable-length character columns.

A) CHAR       B) VARCHAR  C) BLOB      D) TEXT

  1. In order to use the ROLLBACK commands in MySQL, you need to change the value for _____ to 0.
A. COMMIT       B. ROLLBACK
C. AUTOCOMMIT  D. NONE

  1. post_max_size directive is used to set the maximum size of –
A. uploaded file                B. post information
C. php script                      D. all


  1. To invalidate the current session completely which session function is used?
A. session_unset()              B. session_reset()
C. session_destroy()           D. all


  1. mail() function’s 2nd parameter contains message –
A. subject                         B. header
C. body                             D. all

  1. In MySQL, dates have the form _____.

A.MM-DD-YYYY      B. DD-MM-YYYY
C.YYYY-MM-DD      D. YYYY-DD-MM

  1. Which of the following is the correct SQL statement to use to remove rows from a table?
    1. DROP
    2. REMOVE
    3. DELETE
    4. All of the above

  1. MySQL Access security is controlled through
  1. The ID that the user logged into the server through, and priveliges set up for that account.
  2. A table of valid IP addresses, and priveliges set up for each IP address
  3. The normal login security is sufficient for MySQL, and it does not have any extra controls of its own.
  4. MySQL login accounts, and priveliges set for each account

  1. Which of the following commands should be given to connect as the anonymous user of a MySQL server running on the local host?
  1. mysql –u anon  
  2. mysql –u “ ”
  3. mysql -u       
  4. mysql

  1. Which of the following column does not exist in host table of mysql database?
A. Select_priv           B. Grant_priv
C. Index_priv            D. Table_priv

  1. Which attribute is used to sort the column values in case-sensitive fashion?
A. NATIONAL                      B. BINARY
C. ASCII                                D. UNICODE    

  1. Zero or more values can be chosen from which data type?
A. LONGBLOB                    B. ENUM
C. SET                                   D. MEDIUMTEXT

  1. Which numeric datatype stored as a string?
A. BIGINT                              B. DECIMAL
C. DOUBLE                            D. FLOAT

  1. If the any of the column type is xTEXT which type of MyISAM variant is automatically used?
A. static                                  B. Dynamic
C. compressed                      D. all

  1. What port number is used by default to communicate with MySQL server?
A. 3303                              B. 3306
C. 3309                              D. 3312

  1. To export data from mysql server which utilities are used?
A. mysqldump                         B. mysqlshow
C. mysqlhotcopy                      D. all

  1. How many ways session handling can be done?
A. 2         B. 3          C. 4              D. 5

  1. Which function can be used to column names of any table?
A. mysql_fetch_field()        B. mysql_fetch_col()
C. mysql_list_fields()          D. mysql_field_name()

IDB-BISEW IT Scholarship Project
WPSI Round -26
PHP and MySQL Descriptive Question and Answer Exam No: 5 Month: January 2016

Chapter 20: Web Services

  1. What are web services?
Web Services are typically application programming interfaces (APIs) or web APIs that are accessed via Hypertext Transfer Protocol (HTTP) and executed on a remote system hosting the requested services.

  1. What are the benefits of using web services?
The benefits of using web services are
  • The ability to treat software as a service
  • Significantly improved Enterprise Application Integration (EAI) processes
  • Global reusability
  • Ubiquitous accessibility.

  1. What is RSS feed?
RSS refers Really Simple Syndication. It offers a formalized means for encapsulating a web site’s content within an XML-based structure, known as a feed.

Chapter 21: Securing Your Web Site

  1. What is data encryption?
Encryption can be defined as the translation of data into a format that is intended to be unreadable by anyone except the intended party.

Chapter 25-29: MySQL

  1. What is query caching?
Query caching is one of the MySQL’s greatest speed enhancements. Simple and highly effective when enabled, allows MySQL to store SELECT queries, along with their corresponding results in memory.
  1. What is storage engine?
The storage engines manage data storage and index management for MySQL. The MySQL server communicates with the storage engines through a defined API. Example of some storage engines are: InnoDB, MyISAM, MEMORY etc.
  1. What are the advantages of Innodb table?
The advantages are:
  • It can update-intensive tables
  • Support transactional databases
  • Manage sensitive data
  • Capable of automatically recovering from a crash.

  1. What are the differences between primary key and unique?
  1. Each record of the table is identified by Primary key whereas unique key can’t.
  2. Primary key doesn’t support null value but unique key support repeatable null value.  
  1. What are the purposes of GRANT and REVOKE commands?
Answer: The GRANT and REVOKE commands are used to manage access privileges. GRANT command needs to assign new privileges to a user or group of users whereas the REVOKE command is responsible for deleting previously granted privileges from user or group of users.

Example:
mysql> GRANT select, insert ON library.book TO jone@localhost IDENTIFIED BY 'open123';
mysql> REVOKE insert ON library.book TO jone@localhost;
  1. What is the benefit of using prepare statement?
  • To help resolve the issues incurred by repeatedly executed queries, prepared statement is used.
  • To accomplish the repetitive tasks at a significantly lower cost of overhead, and with fewer lines of code.
  1. What are the advantages of stored routine?
  • Consistency –prevent redundant development process.
  • Performance- maintaining queries centrally.  
  • Security- access of sensitive data can be restricted.

  1. What are the benefits of using triggers?
  • Audit trails – able to create an additional special logging table.  
  • Validation – minimum-order threshold can be ensured.
  • Referential integrity Enforcement- table relationship can remain stable throughout the lifetime of the project using trigger

  1. What are the advantages of using view?
  • Simplicity- prevents repeatedly querying multiple tables to retrieve information.
  • Security- provides security for secure data.
  • Maintainability- it is easier to maintain.

  1. What is cursor? Why is it used?
The pointer which is used to iterate through a result set is called cursor. It allows us to retrieve each row in the set separately and perform multiple operations on that row without affecting other row.

  1. What are the advantages of using indexes?
  • Query optimization: database searches can be most efficiently executed when the target data is sorted.
  • Uniqueness: guaranteeing uniqueness for each row.
  • Text searching: it’s possible to optimize searching against even large amounts of text located in any field indexed as such.

   16.What is transaction?
    A transaction is an ordered group of database operations that are treated as a single unit.

      17.How can you export data in mysql?
We can export data in two ways:
  • mysqldump client is used to export existing table data, table structures, or both from the MySQL server.
  • SELECT * INTO OUTFILE "data.txt"
FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
FROM company.sales;

  1. Difference between before trigger and after?
A before trigger shouldn’t be used to enforce propagation or referential integrity. An after trigger should be used when data is to be propagated or verified against other tables and for carrying out calculations.

  1. What is the difference between fetch_row () and fetch_array()?
  • The fetch_row() method is actually capable of retrieving each row of the result set as numerical  array but
  • fetch_array() method is capable to retrieving associative array, a numerical array, or both.

  1. What is binding variables?
When a query has been prepared and executed, we can use bind variables to the retrieved fields by using  the bind_result() method.

Answer: Binding variables is a variable to which we can bind any table field to it so that if we update binding variable that will effect to table field directly. However binding can be one or two way. In two way binding we can read-write data to table field with binding variable and one way binding is readonly.
  1. What is the difference between MYISAM and InnoDB engine?
The main difference is InnoDB supports transactions. You can do commit and rollback in InnoDB table. Whereas MyISAM doesn't support the transaction, once you issue command, can't rollback.

  1. What are the functions of --execute and --force option of mysql?
--execute or -e query: Executes a query without having to actually enter the client interface.
--force or -f: This option causes execution to continue regardless of errors.

  1. What are the purposes of INFORMATION_SCHEMA database?
The INFORMATION_SCHEMA offers a solution for using typical SELECT queries to learn more about databases and various server settings.

Lipon Sir

Chapter 20: Web Services

  1. What are web services?
Web Services are typically application programming interfaces (APIs) or web APIs that are accessed via Hypertext Transfer Protocol (HTTP) and executed on a remote system hosting the requested services.

  1. What are the benefits of using web services?
The benefits of using web services are
  • The ability to treat software as a service
  • Significantly improved Enterprise Application Integration (EAI) processes
  • Global reusability
  • Ubiquitous accessibility.

  1. What is RSS feed?
RSS refers Really Simple Syndication. It offers a formalized means for encapsulating a web site’s content within an XML-based structure, known as a feed.

Chapter 21: Securing Your Web Site

  1. What is data encryption?
Encryption can be defined as the translation of data into a format that is intended to be unreadable by anyone except the intended party.

Chapter 25-29: MySQL

  1. What is query caching?
Query caching is one of the MySQL’s greatest speed enhancements. Simple and highly effective when enabled, allows MySQL to store SELECT queries, along with their corresponding results in memory.
  1. What is storage engine?
The storage engines manage data storage and index management for MySQL. The MySQL server communicates with the storage engines through a defined API. Example of some storage engines are: InnoDB, MyISAM, MEMORY etc.
  1. What are the advantages of Innodb table?
The advantages are:
  • It can update-intensive tables
  • Support transactional databases
  • Manage sensitive data
  • Capable of automatically recovering from a crash.

  1. What are the differences between primary key and unique?
  1. Each record of the table is identified by Primary key whereas unique key can’t.
  2. Primary key doesn’t support null value but unique key support repeatable null value.  
  1. What are the purposes of GRANT and REVOKE commands?
Answer: The GRANT and REVOKE commands are used to manage access privileges. GRANT command needs to assign new privileges to a user or group of users whereas the REVOKE command is responsible for deleting previously granted privileges from user or group of users.

Example:
mysql> GRANT select, insert ON library.book TO jone@localhost IDENTIFIED BY 'open123';
mysql> REVOKE insert ON library.book TO jone@localhost;
  1. What is the benefit of using prepare statement?
  • To help resolve the issues incurred by repeatedly executed queries, prepared statement is used.
  • To accomplish the repetitive tasks at a significantly lower cost of overhead, and with fewer lines of code.
  1. What are the advantages of stored routine?
  • Consistency –prevent redundant development process.
  • Performance- maintaining queries centrally.  
  • Security- access of sensitive data can be restricted.

  1. What are the benefits of using triggers?
  • Audit trails – able to create an additional special logging table.  
  • Validation – minimum-order threshold can be ensured.
  • Referential integrity Enforcement- table relationship can remain stable throughout the lifetime of the project using trigger

  1. What are the advantages of using view?
  • Simplicity- prevents repeatedly querying multiple tables to retrieve information.
  • Security- provides security for secure data.
  • Maintainability- it is easier to maintain.

  1. What is cursor? Why is it used?
The pointer which is used to iterate through a result set is called cursor. It allows us to retrieve each row in the set separately and perform multiple operations on that row without affecting other row.

  1. What are the advantages of using indexes?
  • Query optimization: database searches can be most efficiently executed when the target data is sorted.
  • Uniqueness: guaranteeing uniqueness for each row.
  • Text searching: it’s possible to optimize searching against even large amounts of text located in any field indexed as such.

   16.What is transaction?
    A transaction is an ordered group of database operations that are treated as a single unit.

      17.How can you export data in mysql?
We can export data in two ways:
  • mysqldump client is used to export existing table data, table structures, or both from the MySQL server.
  • SELECT * INTO OUTFILE "data.txt"
FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
FROM company.sales;

  1. Difference between before trigger and after?
A before trigger shouldn’t be used to enforce propagation or referential integrity. An after trigger should be used when data is to be propagated or verified against other tables and for carrying out calculations.

  1. What is the difference between fetch_row () and fetch_array()?
  • The fetch_row() method is actually capable of retrieving each row of the result set as numerical  array but
  • fetch_array() method is capable to retrieving associative array, a numerical array, or both.

  1. What is binding variables?
When a query has been prepared and executed, we can use bind variables to the retrieved fields by using  the bind_result() method.

Answer: Binding variables is a variable to which we can bind any table field to it so that if we update binding variable that will effect to table field directly. However binding can be one or two way. In two way binding we can read-write data to table field with binding variable and one way binding is readonly.
  1. What is the difference between MYISAM and InnoDB engine?
The main difference is InnoDB supports transactions. You can do commit and rollback in InnoDB table. Whereas MyISAM doesn't support the transaction, once you issue command, can't rollback.

  1. What are the functions of --execute and --force option of mysql?
--execute or -e query: Executes a query without having to actually enter the client interface.
--force or -f: This option causes execution to continue regardless of errors.

  1. What are the purposes of INFORMATION_SCHEMA database?
The INFORMATION_SCHEMA offers a solution for using typical SELECT queries to learn more about databases and various server settings.

Prepared By:
Md. Mahabubur Rahman
Captain, WPSI-26, IBCS-PRIMAX

IDB-BISEW IT Scholarship Project
WPSI Round -26
Student Name: ID: Exam No: 5 Month: January 2016
Chapter-20
  1. The _____________plays an enormously important role in the implementation of Web Services?
  1. SOAP protocol
  2. FTP Protocol
  3. HTTP Protocol
  4. XML Protocol

  1. Which of the following statement is true about Web Services?
  1. Web Service is a network service to support interoperable machine-to-machine interaction over a network
  2. Web Service is a mailing systems to send a mail  over a network
  3. Web Service is a software system designed to support interoperable machine-to-machine interaction over a network

  1. RSS offers a formalized means for encapsulating a Web site’s content within an XML-based structure, known as a feed
  1. True  B. False

  1. XML document is stored in a variable, which function  use to read it into the object?
  1. simplexml_load_string()
  2. simplexml_load()
  3. xml_load_string()
  4. load_string()

  1. How to retrieve the XML Attributes?
  1. Use attributes() method
  2. Use element() Method
  3. Use root() Method

  1. FTP  is a lightweight protocol intended for exchanging structured information in  decentralized, distributed environment
  1. True B. False     

Chapter – 21

  1. Which function offers a great tool for viewing a summary of PHP’s configuration on a given server?
  1. The phpinfo()
  2. The info()
  3. The ApachiInfo()

  1. __________can be defined as the translation of data into a format that is intended to be unreadable by anyone except the intended party.
  1. Encryption
  2. Decryption

  1. Which algorithm can also be used as a password verification system?
  1. Encryption
  2. MD5
  3. MHash

  1. Which data encryption package providing support for two-way encryption?
  1. MD5 C. Mcrypt
  2. MHash D. Dcript

  1. The ______________function encrypts data, returning the encrypted result?
  1. mcrypt_encrypt()
  2. encrypt()
  3. mcrypt()

Chapter-25

  1. Mysql is a Relational Database
  1. True  B. False                   

  1. Which of the following are MySql Features?
  1. Replication
  2. Query Caching
  3. Storage
  4. Security

  1. What are the MySql License Options?
  1. MySql Open Source License
  2. MySql Personal Edition License
  3. Commercial License
  4. Enterprise Edition License

  1. Which of the following are MySql 5.0 Features?
  1. Complete Foreign key Support
  2. Stored Procedure Support
  3. Integrated Report support
  4. Batch Query Support

  1. What are the storage engine of MySql?
  1. HDD
  2. InnoDB
  3. MyISAM
  4. Backup
Chapter 25 & 26
  1. How to set the administrator password?
  1. SET ADMINISTRATOR FOR root@localhost=PASSWORD('secret');
  2. SET ROOT PASSWORD  FOR root@localhost=PASSWORD('secret');
  3. SET PASSWORD FOR root@localhost=PASSWORD('secret');
  4. SET PASSWORD FOR Admininstrator@localhost=PASSWORD('secret');

  1. Which of the following are true about MySqL Client?
  1. capable of managing almost every conceivable aspect of a MySQL server, including creating, modifying, and deleting tables and databases
  2. Capable of Database backup, Restore etc.
  3. Viewing Configuration Variables and System Status

  1. Which command use to view all the tables?
  1. View Tables
  2. Show Tables
  3. Display Tables

  1. To view a list of all existing databases
  1. View Databases
  2. Show Databases
  3. Display Databases

  1. How to view the structure of one of those tables?
  1. Structure Student
  2. Display student
  3. Describe student
  4. View Student
Chapter-27
  1. MySQL’s storage engines, namely
  1. ARCHIVE
  2. Index
  3. XLS,
  4. InnoDB
  5. MyISAM.

  1. A relational database  ___________ is a data structure used to store and organize information.
  1. View
  2. Table
  3. Report
  4. Stored Procedure
  1. MyISAM tables handle transactions, meaning that you should use this type for all
of your transactional needs, so as not to incur the extra overhead required of transactional.
  1. True   B. False

  1. Which command use to view storage engine list?
  1. View Engine
  2. Show Storage
  3. Show Engines

  1. How Do I Convert ISAM Tables to MyISAM Tables?
  1. MODIFY TABLE table_name TYPE=MYISAM;
  2. ADD  TABLE table_name TYPE=MYISAM;
  3. ALTER TABLE table_name TYPE=MYISAM;
  1. What is the maximum size of the VARCHAR Column type?
  1. 255 Byte
  2. 255 Characters
  3. 512 Byte
  4. 512 Characters
Chapter-28
  1. How the Privilege System Works?
  1. Authentication
  2. Grant
  3. Revoke
  4. Authorization

  1. ___________Determines whether a user is even allowed to connect to the server.
  1. Authentication
  2. Authorization

  1. Where Is Access Information Stored?
  1. MySQL Datbase
  2. User Database
  3. User Define Database

  1. Which mysql command use to drop a user?
  1. DROP  from user jason@localhost;
  2. Delete from  user jason@localhost;
  3. Delete user jason@localhost;
  4. DROP user jason@localhost;

  1. Which mysql command use to rename user?
  1. CHANGE USER jason@localhost TO jasongilmore@localhost
  2. RENAME  USER jason@localhost;
  3. RENAME USER jason@localhost TO jasongilmore@localhost
Chapter- 30
  1. What are the key features of MySql extension?
  1. Object oriented:
  2. T Embedded Client support
  3. Transactional support:

  1. Which Method use to select MySql Database?
  1. mysqli__db (mysqli link, string dbname)
  2. mysqli_select_database (mysqli link, string dbname)
  3. mysqli__database (mysqli link, string dbname)
  4. mysqli_select_db (mysqli link, string dbname)

  1. Which function is responsible for closing the connection?
  1. mysql_Exit (mysqli link)
  2. mysql_close (mysqli link)
  3. mysql_Nothing (mysqli link)

  1. What is the difference between mysqli_fetch_object (mysqli_result result) and mysqli_fetch_array (mysqli_result result)?
  1. mysqli_fetch_object  except that an object is returned rather than an array.
  2. Both Function are similar
  3. mysqli_fetch_object  except that an any value is returned rather than an array.

  1. commit method commits the present transaction to the database, returning TRUE on success and FALSE otherwise.
  1. True B. False
Another Sheet (Sheet 2):
01.  Where is the greatest use of mysql server?
(a)   Full text indexing and searching (b)   Query caching  (c)    Replication  (d)  Updating

02.  To use the mysqli extension which line is need to add?
(a)   extension = php_mysql.dll
(b)   extension = php_mysqli.dll
(c)    with.mysql[= DIR]  (d)    php.info()     

03.  Which is the comment symbol in mysql?
(a)   &&      (b)   /*....*/     (c)    #     (d)    %       

04.  By default MySQL communicates on-
(a)   port 16 (b)   pot TCO/IP (c)    port 4.01
(d)    port 3306

05. The mysql clients is an extremely useful?
(a)   sql shell  (b)   mysql shell  (c)    programming shell
(d)    object shell  

06.   How to view all tables in mysql?
(a)   view tables (b)   show tables
(c)    select tables (d)    atlar tables  

07. How to show structure of one table
(a)   Describe database name tables name
(b)   Alter database name tables name
(c)    Show database name tables name
(d)    None of the above

08.  How to show variables?
(a)   show variables (b)   view variables?
(c)    save variables? (d)    all of the above   

09. Why we can use LIKE commands?
(a)   To connect data (b)   To conjunction data
(c)    To looking data (d) Matching data   

10. How to view a new database?
(a)   view database   (b)   Show databases
(c)    Describe database (d) Create database Co:

11. How to create a new database?
(a)   create database Name (b) describe database name
(c) creative database name (d) Noe of the above

12.   How to delete database?
(a)   create database (b)   drop database
(c)    delete database (d)    alter database      

13.   How many type in database type categories?
(a)   Three   (b) four    (c) five    (d)  six

14.   Which are database type categories?
(a)   Date & time (b)   numeric
(c)    string (d)    integer

15.   Which format display mysql data values?
(a)   yyyy-dd-mm (b)   dd-mm-yyyy
(c)    mm-dd-yyyy (d)    yyyy-mm-dd   

16. Which format display mysql date time values?
(a)   yyy-dd-mm hh:mm:ss     (b) mm-dd-yyyy hh:mm:ss
(c)    dd-yyyy-mm hh:mm:ss   (d) yyyy-mm-dd hh:mm:ss

17. Which function return an error massage?
(a)   mysql_error(); (b)   mysql_errors();
(c)    mysql--error(); (d)    mysql--er();        
18. A set of SQL statements stored in the database  and executed by calling an assigned name within a query in known as what?
(a)   stored routine (b)   stored procedures
(c)    stored functions (d)    stored tables  

19. Which is/are referred as stored routing?
(a)   stored procedure (b)   stored functions
(c)    privilege table (d)    application code  

20. Stored procedures support execution of which SQL commands?
(a)   only the SELECT command
(b)   SELECT & INSERT commands
(c)    Only the UPDATE command
(d)    SELECT, INSERT, DELETE, UPDATE commands

21. Which command is used to end an existing stored procedure?
(a)   DROP PROCEDURE procedure_name
(b)   DROP PROCEDURE procedure name
(c)    DROP PROCEDURE "procedure_name"
(d)    DROP FUNCTION procedure_name      

22.  What is are belong to stored routine's advantage?
(a)   capability (b)   performance (c)    consistency
(d)    portabilty

23. For stored procedure's input parameter we need to declare what?
(a)   The name  (b)   Data type  (c)    functions
(d)    Parameter's purpose using keywords     

24. What is/are the keywords used to declare parameter's purpose?
(a)   IN   (b)   OUT  (c)   OUTIN  (d)    INOUT

25. When declaring input parameters for stored functions what we have to include?
(a) Parameter's name and type   (b) Parameter's datatype
(c) Parameter's purpose  (d) Parameter's duration

26. Parameter's name must be prefaced with what symbol to declare it as OUT or INOUT?
(a)   $symbol (b)   @symbol (c)    &symbol
(d)    _symbol

27. What is the maximum size of the VARCHAR column type?
(a)   255 Bytes (b)   255 Characters
(c)    512 Bytes (d)    512 Characters  

28. An example of a simple stored procedure is as flowing :
mysql>CALL get_inventory()->SELECT 45 AS inventory;
Which command is used to execute this procedure?
(a)   mysql>CALL get_inventory()
(b)   mysql>CALL call_inventory()
(c)    mysql>CALL grant_inventory()
(d)    mysql>CALL revoke_inventory()     

29. Let us consider a table "product" consist of two columns and on entry what will be the output of following php code after connecting a database?
$query = "SELECT id, name, FROM product";
$result = mysql_query($query);
$res = mysql_num_rows($result);
echo $res;
(a)   1 (b)   2 (c)    3 (d)    0

30. Why used mysqli-fetch_array()?
(a)   Once has been executed and result set readied.
(b)   Once the query has been executed and result set readied.
(c)    for retrieving the fields comprising each row.
(d)    None of them
Another Sheet (Sheet 3):
  1. Consider the following code snippet. What would go in place of the ???? above for this script to function properly? (Choose 1 answer)
<?php
$link = mysqli_connect("hostname","username","password");
if(!$link)
{
  $error = ??????
  die("Could not connect to the database: $error");
}
?>
(a)   mysqli_connect_error();
(b)   mysqli_connect_error($link);
(c)    mysqli_error();
(d)    $_MySQL['connect_error']

  1. Which of the following data types cannot be directly manipulated by the client?
(a)   Cookie Data
(b)   Session Data
(c)    Remote IP Address
(d)    User Agent

  1. Transactions can be used to: (Choose 2)
(a)   Recover from errors in case of a power outage or a failure in the SQL connection
(b)   Ensure that the data is properly formatted
(c)    Ensure that either all statements are performed properly, or that none of them are.
(d)    Recover from user errors

  1. What is the output of the following code?
<?php
$string = "14302";
$string[$string[2]] = "4";
print $string;
?>
(a) 14304     (b) 14342     (c)  44302    (d) 14402  

  1. SQL security characteristic is set what?
(a)   DEFINER (b)   INVOKER    (c)    TRIGGER
(d)    MODIFIER

  1. Store procedure's characteristic READE SQL DATA indicate to what?
(a)  SQL is present (b)   SQL will read data
(c)  SQL will only retrieve data
(d) SQL read and modify data  

  1. What does retrieve mysql_list_table(); function?
(a)   all table name (b) only one table
(c)    more than on table (d) cause an error

  1. What is function used for close mysql database connection?
(a)   mysql_close() (b)   mysqli_close()
(c)    mysql->close() (d)    mysqli->close()    

  1. Which function can use to connect database on server rather than use mysql_connect()?
(a)   mysqli_connect (b) mysqli->connect
(c)    mysqli_>connect (d)  mysqli->select_db  
  1. mysqli_connect_error()function returns an error massage for error product by the.........?
(a)   last call to $mysql->connect
(b)   first call to $mysql->connect
(c)    middle call to $mysql->connect
(d)    a and b

  1. Which is correct general from of function mysql_query()?
(a)   resource mysql_query (binary query[resource link_id])
(b)   resource mysql_query (string query[resource link_id])
(c)    resource mysql_query (binaryboolean query[resource link_id])
(d)    boolean mysql_query (string query[resource link_id])
  1. When a user connect to database the user name must?
(a)   Case insensitive (b)   Case sensitive
(c)    Both a and b (d)    None

  1. Which is method use switch to a new database?
(a)   $mysqli->select_db("") (b)   mysql->select_db("")
(c)    mysqli->select_db()   (d)    all of the above   

  1. Local variables declared within a stored routine using what statement?
(a)   DEFINE (b)   ASSIGN (c)    INVOKE
(d)    DECLARE

  1. Which is the largest integer range?
(a)   BIGINT   (b)   INT  (c)    MEDUWMINT
(d)    SMALLINT   

  1. Which is the second largest integer range/
(a)   BIGINT (b)   MEDUMINT
(c)    INT (d)    SMALLINT

  1. The VARCHAR data type offer-------- string representation
(a)   varchar-length (b)   fixed-length
(c)    variable-length (d)    attribute-length   

  1. When you need to assign new privileges to a user for group of users?
(a)   revoke command     (b)   Grant command
(c)   Connect  command  (d)  Assign command    

  1. Which command is responsible for deleting previously granted privileges from a user or a group of users?
(a)   Revoke command     (b)  Grand command
(c)    Connect command   (d)  Assign command   
  1. How many parameter need to connect with data base?
(a)   1   (b)   2       (c)    3     (d)    4
Another Sheet (Sheet 4):
  1. Which is the third largest integer range?
(a)   BIGINT (b)   INT
(c)    MEDUMINT (d)    SMALLINT
  1. Which is the forth-largest integer rang?
(a)   BIGINT (b)   INT
(c)    MEDUMINT (d)    SMALLINT
  1. Which is the small integer range?
(a)   INT   (b)   TINYINT  
(c)    SMALLINT (d)    None of them

  1. Which is the double precision floating point number?
(a)   semi-double (b)   float
(c)    single  (d)    double
  1. The CHAR data type offer--------string representation?
(a)   fixed-length (b)   variable-length
(c)    attribute-length (d)    char-length

  1. What is the maximum value support in CHAR data type?
(a)   256   (b)   255    (c)    254   (d) 65255   

  1. what  is the maximum value support in VARCHAR data type
(a)   254    (b)   255   (c)    256   (d)    65535   
  1. What is the largest binary string representation?
(a)   LONGBLOB (b)   LONGTEXT
(c)    MEDIUMBLOB   (d)    MEDIUMTEXT  

  1. What is the largest non-binary string representation?
(a)   LONGBLOB    (b)   LONGTEXT
(c)    MEDIUMBLOB   (d)    MEDIUMTEXT     

  1. What is the second largest binary string representation?
(a)   LONGBLOB  (b)   LONGTEXT
(c)    MEDIUMBLOB  (d)    MEDIUMTEXT  

  1. What is the second-largest non-binary string representation?
(a)   LONGTEXT  (b)   LONTBLOB  
(c)    MEDIUMBLOB  (d)    MEDIUMTEXT    
  1. What is the third-largest binary representation?
(a)   TEXT    (b)   BLOB    (c)   LONG  
(d) MEDIUM   

  1. What is the third-largest none-binary representation?
(a)   TEXT    (b)   BLOB  
(c)    LONGBLOB  (d)    MEDIUMBLOB  
  1. What is the smallest binary representation?
(a)   LONGBLOB (b)   LONGTEXT
(c)    TINYBLOB (d)    TINYTEXT
  1. What is the smallest non-binary representation?
(a)   LONGNBLOB (b)   LONGTEXT
(c)    TINYBLOB (d)    TINYTEXT        

  1. Which are the data type attribute?
(a)   auto-increment (b)   binary
(c)    index (d)    string

  1. Where are you write "extension = php_mysql.dll" to add mysqli extension in window?
(a)   php.ini (b)   php.info (c)    mysql.ini
(d)    mysql.info

  1. Which of the following is/are true for stored funtions?
(a)   support execution only by the SELECT command
(b)   accept only input parameter & return one and only one value
(c)    can be embedded directly into a SQL command
(d)    used to manipulate data in database or perform special calculation

  1. When declaring variable it must take place within which block?
(a)   START/FINISH block  (b)   BEGIN/END block
(c)    DELIMITER/DELIMITER block  (d)    OPEN/CLOSE block

  1. What statement/s is/are used to set the value of a declared stored routine variable?
(a)  SET statement       (b) SELECT..... INTO statement
(c)  SELECT statement  (d) SET..... INTO statement  

  1. What is the value of $result in the following PHP code?  
<?php
    function timesTwo($int)
   {  $int = $int * 2;     }
    $int = 2;
   $result = timesTwo($int);
?>    (a)   null (b)   2 (c)    -2 (d)    4
  1. The code below __________ because __________.
<?php
    class Foo
   {
?>
<?php
        function bar()
       {
           print "bar";
       }
    }
?>
(a)   will work, class definitions can be split up into multiple PHP blocks.
(b)   will not work, class definitions must be in a single PHP block.
(c)    will not work, class definitions must be in a single file but can be in multiple PHP blocks.
(d)    will work, class definitions can be split up into multiple files and multiple PHP blocks.   

  1. Consider the following code snippet. Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string? (Choose 1 answer)
<?php
$query = "INSERT INTO mytable
(myinteger, mydouble, myblob, myvarchar)
VALUES (?, ?, ?, ?)";
$statement = mysqli_prepare($link, $query);
if(!$statement)
{
  die(mysqli_error($link));
}
/* The variables being bound to by MySQLi
don't need to exist prior to binding */

mysqli_bind_param($statement, "idbs",
$myinteger, $mydouble, $myblob, $myvarchar);
/* ???????????? */
/* execute the query, using the variables as defined. */
if(!mysqli_execute($statement))
{
  die(mysqli_error($link));
}
?>
(a)   A transaction must be begun and the variables must be assigned
(b)   Each value must be assigned prior to calling mysqli_bind_param(), and thus nothing should be done
(c)    Use mysqli_bind_value() to assign each of the values
(d)    Assign $myinteger, $mydouble, $myblob, $myvarchar the proper values

  1. Consider the following code snippet, assuming this code snippet is part of a larger correct application, what must be done in place of the ???? above for the correct output to be displayed? (Choose 1 answer)
<?php
$query = "SELECT first, last, phone FROM contacts WHERE first LIKE 'John%'";
$statement = mysqli_prepare($link, $query);
mysqli_execute($statement);
/* ???? */
while(($result = mysqli_stmt_fetch($statement)))
{
  print "Name: $first $last\n";
  print "Phone: $phone\n\n";
}
? >
(a)   None of the above
(b)   mysqli_fetch_columns($first, $last, $phone);
(c)    mysqli_stmt_bind_result($statement, $first, $last, $phone);
(d)    A while loop, fetching the row and assigning $first, $last, and $phone the proper value

  1. Which of the following cases are cases when you should use transactions? (Choose 1 answer)
(a)   Updating a single row in a table
(b)   Inserting a new row into a single table
(c)    Selecting rows from multiple different tables
(d)    Updating a single row in multiple different tables

  1. Which options do you have in PHP to set the expiry date of a session?
(a)   Set the session.duration directive in php.ini
(b)   Set session cookie expiry date locally via session_set_cookie_params()
(c)    Set session expiry date locally via session_cache_expire()
(d)    None of the above

Another Sheet (Sheet 5):
  1. Which the correct coding for executing variables of mysql?
(a)   mysql.show variable "table_type"
(b)   mysql.show variables like "table_type"
(c)    mysql.show stats  (d)    None

  1. max_allowed_packet, a packet is equivalent to both multiple SQL statement and multiple row return to the requesting client.
(a)   True (b)   False

  1. How many MySQL privilege system revives around concepts?
(a)   2          (b)   3       (c)    4 (d)    5

  1. How many stage privilege control process?
(a)   2     (b)   3           (c)    4          (d)    5        

  1. Which is/are MySQL’s privilege system?
(a)   Authenticate (b)   Authentication
(c)    Authorization (d)    Authorize   

  1. How many way(s) password stored hashed format?
(a)   One   (b)   Two (c)    three   (d)    Four    

  1. Which is not permitted user name and password?
(a)   CAPITAL LETTER (b)   Number
(c)    small letter  (d)    Wild cards

  1. Address can be stored as either?
(a)   HOST name   (b)   IP address
(c)    or Wild cards  (d)    above all

  1. Which are MySQL access control?
(a) connection authentication
(b)   request verification
(c)    Both a and b (d)    None of them

  1. How many steps of MySQL access control stages?
(a)   Two     (b)   Three  (c)    Five    (d)    Six

  1. How many tables found in data base play in important rule in the authentication and privilege verification process?   
(a)   Three (b)  Four   
(c)    Five   (d)  Six   
  1. Which are correct?
(a)   mysql_real_escape_string();
(b)   mysql_stat();  (c)    mysql_server_info();
(d)    mysql_get_server_info();  

  1. mysql_field_flags() function returns.........?
(a)   all options assigned to the field
(b)   the length of the field
(c)    the name of the field
(d)    an error

  1. What are the names of two tables that are used to manage stored function?
(a)   proc and procs_priv tables
(b)   columns_priv and proc_priv tables
(c)   tables_priv and tabels
(d)   host table table_priv
  1. proc store which information regarding the stored routine?
(a)   syntax (b)   creation data    
(c) parameter list (d)    capability
 
  1. When CASE statement is particularly useful?
(a)   to evaluate conditional statement
(b)   to compare a value against an array of possibilities
(c)    to immediately exit a loop
(d)    to loop over a set of statement    

  1. Executing which statement causes the LOOP REPEAT or WHILE within which it is embedded to return to the top and execute again?
(a)   LOOP (b)   ITERATE
(c)    REPEAT (d)    LEAVE

  1. Which statement is used when someone want to immediately exit a loop of a BEGIN?END block pending the value of a variable or outcome of a particular task?
(a)   LEAVE (b)   END (c)    FINISH
(d)    DELIMITER

  1. How we can save the inconvenience of having to repeat logic unnecessarily?
(a)   Calling a routing from within another routine
(b) Modifying a stored routine  
(c) Using WHILE statement
(d) Deleting a stored routine      

  1. When turned on, __________ will __________ your script with different variables from HTML forms and cookies.
(a)   show_errors, enable (b)   show_errors, show
(c)    register_globals, enhance (d) register_globals, inject
  1. What will be the output of the following PHP code:
<?php
    echo count(strlen("http://php.net"));
?>
(a)   1 (b)   2 (c)    3 (d)    4     

  1. Choose the selection that best matches the following statements:
PHP is a _____ scripting language based on the ____ engine. It is primarily used to
develop dynamic _____ content, although it can be used to generate ____ documents
(among others) as well.

(a)   Dynamic, PHP, Database, HTML
(b)   Embedded, Zend, HTML, XML
(c)    Perl-based, PHP, Web, Static
(d)    Embedded, Zend, Docbook, MySQL       

  1. Which of the following is not a valid default stream wrapper for PHP 5, assuming OpenSSL is enabled?
(a)   ftps:// (b)   ftp://  (c)    sftp://  (d)    http://
  1. If you would like to store your session in the database, you would do which of the following?
(a)   It requires a custom PHP extension to change the session handler
(b)   Implement the session_set_save_handler() function
(c)    Create functions for each session handling step and use session_set_save_handler() to override PHP’s internal settings
(d)    Configure the session.save_handler INI directive to your session class

  1. To ensure that a given object has a particular set of methods, you must provide a method list
in the form of an ________ and then attach it as part of your class using the ________ keyword.
(a)   array, interface (b) interface, implements
(c)    interface, extends  (d)  instance, implements  

  1. You work for a shared hosting provider, and your supervisor asks you to disable user scripts to dynamically load PHP extensions using the dl() function. How can you do this? (Choose 2)
(a)   Set enable_dl to Off in the server's php.ini configuration file.
(b)   Add dl to the current value of disable_functions in the server's php.ini configuration file.
(c)    Add dl to the current value of disable_classes in the server's php.ini configuration file.
(d)    Write a custom function called dl(), save it under the name prepend.inc and then set the auto_prepend_file directive to prepend.inc in php.ini.

  1. Which of the following statements is NOT true?
a) Class constants are public
b) Class constants are being inherited
c) Class constants can omit initialization
(default to NULL)
d) Class constants can be initialized by consts

  1. Type hinting in PHP allows the identification of the following variable types: (Choose 2)
(a)   String (b)   Integer
(c)    Array
(d)    Any class or interface type   

  1. Which options do you have in PHP to set the expiry date of a session?
(a)   Set the session.duration directive in php.ini
(b)   Set session cookie expiry date locally via session_set_cookie_params()
(c)    Set session expiry date locally via session_cache_expire()
(d)    None of the above

  1. A script residing at http://example.com/phpcert/cookies.php contains the following code:
1 <?php
2 setcookie('name1', 'value1', time() + 60*60*24, '/');
3 setcookie('name2', 'value2');
4 ?>
The web browser is configured to accept all cookies. How many cookies will be set by this script?
(a)   0 (b)   1 (c)    2 (d)    3
  1. Which one of following is correct?
(a)   mysql_affected_rows();   (b)   mysql_list_dbs();
(c)    mysql_db_name();    (d)    mysql_list_tables();  

  1. Which of the following statements is correct?
(a)   Interfaces can extend only one interface
(b)   Interfaces can extend more than one interface
(c)    Interfaces can inherit a method from different interfaces
(d)    Interfaces can redeclare inherited methods

  1. Which of the following cases are cases when you should use transactions? (Choose 1 answer)
(a)   Updating a single row in a table
(b)   Inserting a new row into a single table
(c)    Selecting rows from multiple different tables
(d)    Updating a single row in multiple different tables

  1. In PHP the error control operator is _______
  1. .
  2. *
  3. @
  4. &

  1. Which of the following function is used for terminate the script execution in PHP?
  1. break()
  2. quit()
  3. die()
  4. None of them

  1. What is the difference between trigger_error() and user_error()?
  1. trigger_error() also allows a script to throw system-level errors
  2. user_error() also allows a script to throw system-level errors
  3. user_error() cannot be used in an error handler and trigger_error() is only available in PHP 5
  4. There is no difference

  1. Which of the following are good steps to undertake when setting up a production webserver?  
(Choose 2)
  1. Turning off error reporting
  2. Turning on error logging
  3. Turning off error logging
  4. Turning off the display of errors

  1. Which of the following is not an SQL aggregate function?
(a)   AVG
(b)   SUM
(c)    MAX and MIN
(d)    CURRENT_DATE()

  1. Which of the following correctly identify the requirements for a column to be part of the result set of a query that contains a GROUP BY clause?
(a)   The column must be indexed
(b)   The column must be included in the GROUP BY clause
(c)    The column must contain an aggregate value
(d)    The column must be a primary key

  1. The mysql function in php are-----?
(a)   Case sensitive (b)   Case insensitive
(c)    variable (d)    constant       

  1. Why the bianry-key used in database?
(a)   unique identify column (b)   unique identify row
(c)    both a and b (d)    none of the above

Another Sheet (Sheet 6):
  1. What statement is/are false for web services?
A. used to work on single machine
B. write once and reuse anywhere
C. it is a software
D. all  

  1. To get particular node value which method of simpleXML is used?
A. asXML()                        B. children()
C. xpath()                          D. attribute()

  1. Which of the following storage engine is operating system independent?
A. InnoDB                              B. EXAMPLE
C. MyISAM                            D. MEMORY

  1. Which storage engine does not support VARCHAR dayatype?
A. InnoDB                              B. FEDERATED
C. MyISAM                            D. MEMORY

  1. Which of the following is the MySQL’s third largest integer datatype?
A. INT                                  B. SMALLINT
C. TINYINT                         D. none

  1. Which of the following commands should be used to create a database named “company”?
A.CREATE DATABASE company
B. CREATE –I company
C. DATABASE / company
D. mysql –s company

  1. Internally information is held in tables. Which of these is NOT a valid format:
A. InnoDb         B. MyIsam
C. Isam              D. Isam99

  1. Which of the following can add a row to a table?
A.  Commit    B.  Add
C.  Alter          D. Insert

  1. Which of the following encryption package perform two-way encryption?
A. MD5     B. mhash       C. MCrypt          D. all

  1. In which of the follwing SQL statements is the keyword SET used?
a. UPDATE  b. DELETE
c. SELECT   d. APPEND

  1. SQLite is a –
A. server        B. file      C. table     D. none

  1. To manage data into MySQL server which mechanism is/are used?
A. Query                              B. table handler  
C. Storage Engine              D. all

  1. Which of the following feature is called MySQL’s one of the greatest speed enhancements?
A. security                           B. Replication
C. Query Caching               D.  Indexing

  1. Which SQL statement is used to insert a new data in a database?
a) INSERT INTO  b) UPDATE
c) ADD                  d) INSERT NEW

  1. You use the _____ clause to list data in a specific order.
A.GROUP BY            B. SORT BY
C.ORDER BY            D. HAVING

  1. What happens if you run a DELETE command that does not contain a WHERE clause?
A. Single row will be deleted
B. First row will be deleted
C. Last row will be deleted
D. All rows will be deleted from the table.

  1. Which of the following commands lists all the privileges granted to a user?
A. SHOW PRIVILEGES  B. SHOW GRANTS
B. SHOW REVOKE          C. NONE

  1. The database administrator uses the _____ command to revoke privileges from users.
A. REVOKE         B. GRANT
C. COMMIT        D. ROLLBACK

  1. Which mysql function is used to select database and execute query at a time?
A. mysql_select_db()             B. mysql_query()
C. mysql_db_query()              D. mysql_result()

  1. Which of the mysql function(s) return array?
A. mysql_fetch_row()       B. mysql_fetch_array()
C. mysql_fetch_assoc()           D. all  

  1. A SELECT command without a WHERE clause returns?
a) All the records from a table that match the previous WHERE clause
b) All the records from a table, or information about all the records
c) SELECT is invalid without a WHERE clause
d) Nothing

  1. You are required to buy a license for MySQL if
A. You are never required to buy a license
B. You incorporate it into a product that you sell
C. You use MySQL in a live application and not just for evaluation
D. You use it on a publicly accessible site

  1. Automatic crash recovery is available in which storage engine?
A. InnoDB                              B. FEDERATED
C. MyISAM                            D. MEMORY

  1. Which of the following is/are example(s) of third-party client program of php?
A. MySQL Query Explorer   B. MySQL Administrator
C. PHPMyAdmin                    D. Netscape

  1. If the default width of an unsigned INT is 5 then ZEROFILL INT value of 5 will be represented as –
A. 5         B. 50000       C. 00005             D. none

  1. To invalidate the current session completely which session function is used?
A. session_unset()              B. session_reset()
C. session_destroy()          D. all
Prepared By:
Md. Mahabubur Rahman
Captain, WPSI-26, IBCS-PRIMAX