TN Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 1.
What is the feature in Relational Database Management System (RDMS)?
Answer:
Data is important to all computer and Internet related applications. Numerous growths of data need a secure and convenient environment to store and manipulate autonomously.

Question 2.
List some Relational Database Management System (RDMS) software.
Answer:
The Relational Database Management Systems are MySQL, Oracle, IBMDB2, and Microsoft SQLSERVER etc.,

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 3.
Write the major operations perform by SQL.
Answer:
The databases are connected with programming language and perform the major operations like INSERT, SELECT, UPDATE and DELETE using SQL.

Question 4.
What are way covers database connectivity?
Answer:
The database language connectivity, which covers database connection establishment, Database selection, SQL statement execution, and connection termination.

Question 5.
Write the syntax of Mysqli_connect() function.
Answer:
Syntax:
mysqli_connect .(“servername”, “username”, “password”, “DBName”);
where,
Server name – Database server IP address.
User name – Database server Username.
Password – Database server Password.
DB Name – Database Name.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 6.
Define Queries.
Answer:

  • The main goal of MySQL and PHP connectivity is to retrieve and ’ manipulate the data from MySQL database server.
  • The SQL query statements are helping with MySQL extension to achieve the objective of MySQL and PHP connection.

Question 7.
What is RAD (Rapid Application Development)?
Answer:
PHP has also attracted the development of many software frame works that provide building blocks and a design structure to promote Rapid Application Development (RAD).

Question 8.
List some Frameworks software.
Answer:
Some Frameworks software are PRADO, Cake PHP, Symfony, Code Igniter, Laravel, Yii framework, Phalcon and Zend Framework.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 9.
What is HiPHOP’s HPHP’c?
Answer:

  • The HiPHOP’s HPHP’c, which help to convert PHP code into C+ programming code.
  • Facebook also written alternative version of PHP that is HiPHOP’ HPHP’c.

Question 10.
How be the result set of Mysqli handled in PHP?
Answer:
The result set can be handled using
mysqli_fetch_array,
mysqli_fetch_assoc,
mysqli_fetch_object (or) mysqli_fetch_row.

Question 11.
How is it possible to know the number of rows returned in the result set?
Answer:
The function mysqli_num_rows() returns the number of rows in a result set.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 12.
Which function gives us the number of affected entries by a query?
Answer:
mysqli_affected_rows( ) return the number of entries affected by an SQL query.

Question 13.
What is the difference between mysqli_fetch_object() and mysqli_fetch_ array()?
Answer:

  • The mysqli fetch_object( ) function collects the first single matching record.
  • But mysqli_fetch_array() collects all matching records from the table in an array.

Question 14.
Will a comparison of an integer 12 and a string “12” work in PHP?
Answer:
12 and “12” can be compared in PHP since it casts everything to the integer type.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 15.
What is server?
Answer:
A server is a computer or a device that provides functionality for other programs or devices called clients. This architecture is called the client- server model, and a single overall computation is distributed across multiple processes or devices.

Question 16.
Write definition and usage of die( ) function in PHP.
Answer:
(i) The die( ) function prints a message and exits the current script.
(ii) This function is an alias of the exit( ) function, syntax: die (message)
Where,
Message – Required, specifies the message or status number to write before exiting the script. The status number will not be written to the output.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 17.
What does arrow operator (=>) mean in PHP?
Answer:

  1. The arrow operator (=>), is used as an access mechanism for arrays.
  2. This means that what is on the left side of it will have a corresponding value of what is on the right side of it in array context.
  3. The object operator (->) is used in object scope to access methods and properties of an object.

Question 18.
Write a program, the SQL querry retrieve two records from student tabfe in school database and populated into client browser using PHP scripting language.
Answer:
<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;
$dbname = “school_DB”;
$connection = mysqli_connect(‘$servername’, ‘$username’, ‘$password’, ‘$dbname’); if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL:” . mysqli_connect_
error();
}
sql_stmt = “SELECT * FROM my_contacts”; //SQL select query
$result = mysqli_query($connection,$sql_stmt);//execute SQL statement$rows = mysqli_num_rows (Sresult);
// get number of rows returned ‘ if (Srows) { . .
while ($row = mysql.i_fetch_array (Sresult) ) {
{
echo ‘ID:’ . $row[‘id’] . ‘<br>’;.
echo ‘Full Names:’ . $row[‘full_names’] . ‘<br>’;
echo ‘Gender:’ . $row[‘gender’] . ‘<br>’;
echo ‘Contact No:’ . $row[‘contact_no’] . ‘<br>’;
echo ‘Email:1 . $row[’email’] . ‘<br>’;
echo ‘City:’ . $row[‘city’] . ‘<br>’;
echo ‘Country:’ . $row[‘country’1 . ‘<br><br>’;
}
}
mysqli_close(Sconnection); //close the database connection
?>

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 19.
What are the MySQLi function available PHP?
Answer:
PHP MySQLi functions are MySQli_query, MySQli_connect, MySQli_ fetch_array and MySQli_close.

Question 20.
What is MySQLi function?
Answer:
MySQLi function is a relational database driver used in the PHP scripting language to provide an interface with MySQL databases.

Question 21.
What are the types MySQLi function available PHP?
Answer:
The types of MySQLi Function in PHP are MySQli connect ( ) function, MySQlicIoseQ function, MySQliselectdb ( ) function, MySQli_affected_ rows( ) function, MySQIiconnecterror( ) function, MySQli_fetch_assoc( ) function etc.,

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 22.
Difference between Connection and Close function.
Answer:

Connection

 Close

Before accessing MySQL database, connect to database server machine via PHP scripting language using MySQli_connect () functions.  MySQli_clos( ) function is used to close an existing opened database connection between PHP scripting and MySQL database server.
Syntax:  $conn = mysqli_connect($ servername, $username, $password, $DB_name);  Syntax: MySQli_close (“Connection Object”);

Question 23.
Give few examples of MySQLi Quries.
Answer:
MySQLi Quries are SELECT, SHOW, DESCRIBE, FROM, EXPLAIN, etc.,

Question 24.
What is Connection string?
Answer:

  1. In computing, a connection string is a string that specifies information about a data source and the means of connecting to it.
  2. It is passed in code to an underlying driver or provider in order to initiate the connection.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 25.
What is web Database?
Answer:

  1. A web database is a wide term for managing data online.
  2. A web database is a database application designed to be managed and accessed through the internet.

Question 26.
What is mysqli_fetch_assoc( ) Function?
Answer:
The mysqli_fetch_assoc( ) function fetches a result row as an associative array. .
Syntax: The mysqli_fetch_assoc (result) ;
where,
result – Required, specifies a result set identifier returned by mysqli_query( ).

Question 27.
Define mysqli_connect_error() Function.
Answer:

  • The mysqli_connect_error( ) function returns the error description from the last connection error.
  • Syntax: mysqli_connect_error ( ) ;
  • Return value – Returns a string that describes the error. NULL if no error occurred.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 28.
Define mysqli_affected_rows( ) Function.
Answer:
The mysqli_affected_rows( ) function returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query.
Syntax: mysqli_affected_rows (connection) ;
where,
connection – Requried. Specifies the MySQL connection to use.

Question 29.
Write the Syntax for MySQLi Queries.
Answer:

  • Syntax: mysqli_query (“Connection Object”, “SQL Query”) Where,
  • Connection Object – Required. Specifies the MySQL connection to use.
  • SQL Query – Required. Specifies the query string.

Question 30.
Write the purpose of MySQLi function available.
Answer:

  1. MySQLi function, returns an object to use with the mysqli_real_connect( ) function.
  2. MySQLi function asks to the server to kill MySQLi thread specified by the Processed Parameter.
  3. This function checks if there are more results from a multi query.
  4. It used to separate the queries with a semicolon against the database.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 31.
Differentiate mysqli_affected_rows( ) Function and mysqli_fetch_assoc( ) Function.
Answer:

mysqli_affected_rows( )

 mysqli_fetch_assoc( )

The mysqli_affected_rows( ) function returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE or DELETE query.  The mysqli_fetch_assoc() function fetches a result rows as an associative array.
Return values: An integer greater than zero indicates the number of rows affected or retrieved.  Returns an associative array of strings representing fetched row.
-1 indicates that the query returned an error.  NULL if there are no more rows in result set.

Question 32.
Write MySQL Connection Syntax with example.
Answer:
The MySQL connection syntax:
mysqli_connect(“server Name”, “UserName”, “Password”, “DB Name”);
Where,
Server Name – Optional. Specifies a host name or an IP address.
User Name – Optional. Specifies the MySQL username.
Password Name – Optional. Specifies the MySQL password name. DB Name – Optional. Specifies the default database to be used.
Eg:
<?php –
Scon = mysqli_connect(“localhost”, “my_user”, “my-password”, “my-db”);
//check connection if (mysqli_connect_errno( ))
{
echo “Failed to connect to MySQL:”
Mysqli_connect_error ( ) ;
}
?>

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 33.
Write a note PHP MySQL database connection.
Answer:
PHP MySQL database connection to connect database server machine.
To connect PHP MySQL database, steps are follows:

  1. Create database, Now return to the homepage of php myadmin.
  2. Create a folder in htdocs.
  3. Create a database connection File in PHP.
  4. Create new PHP file to check our database connection.
  5. Run it.
  6. Create Database connection.
  7. MySQLi procedural query.
  8. Connect MySQL database with PHP using PDO.

Question 34.
Discuss in detail about MySQL functions with example.
Answer:
MySQL has many built-in functions. It contains string, numeric, date, and some advanced functions in MySQL.

(i) Some MySQL string functions:

(a) ASCII – Returns the ASCII values for the specific character
Syntax: ASCII (character)
Eg:ASCII (Customer Name)

(b) Replace – Replace all occurences of a substring within a string, with a new substring.
Syntax: REPLACE (string, form_string, new_ string) ; Eg:select replace (“SQL NEW”, “SQL”, “HTML”);

(c) REVERSE – Reverse a string and returns the result.
Syntax: REVERSE (string) .
Eg: SELECT REVERSE (“RAMAN”);

(ii) MySQL numeric functions:

(a) AVG – Returns the average value of an expression.
Syntax: AVG (expression)
Eg: AVG (Price);

(b) COUNT – Returns the number of records returned by a selected query.
Syntax: COUNT (expression)
Eg: COUNT (Product ID) ;

(c) MOD – Returns the remainder of a number of divided by another number.
Syntax: MOD (x, y)
Eg: MOD (16, 4) ;

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 35.
Explain the Database error handling and management process in PHP.
Answer:
Error handling is the process of catching errors raised by our program and then taking appropriate action. If we would handle errors properly then it may lead to many unforeseen consequences. Its very simple in PHP to handle errors.
Using die ( ) function:
While writing your PHP program you should check all possible error condition before going ahead and take appropriate action when required.
Eg:
<?php
if (!file_exists (“/tmp/test. txt”) )
{
die (“file not found”);
}
else{
$file=fopen (“/tmp/test. txt”, “r”) ;
Print “opend file successfully”;
)
?>

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 36.
Defining custom error handling process.
Answer:
This function must be able to handle a minimum of two parameters (error level and error message) but can accept upto five parameters.
Syntax: error_function(error_level, error_message, error_file, error_line,error_context) ;

Error Report Levels:
These error report levels are the different types of error the user – defined error handler can be used for EWARNING, ENOTICE, EUSERERROR, E_USER WARNING, EUSERNOTICE, E_RECOVERABLE_ERROR,-E_ALL etc.,
Error Logging – By default, PHP sends an error log to the server’s logging system or a file.

Send an Error Message by E-mail: We will send an E-mail with an error message and end the script, if a specific errors occurs.

Question 37.
Explain in details types of MySQL connection method in PHP.
Answer:
PHP program, which will explain how to connect from your PHP to MYSQ1 database.

  • Connect using mysqli extension.
  • Connect using PDO.
  • Connect using traditional legacy MYSQl_functions.

(i) Connect from PHP using mysqli extension:
Cent os, php MySQli is already part of the php mysql package.
Create the following mysqli. php file under the Apache Document Root:
<?php
$conn = new mysqli (“localhost”, “root”, “DB pass”, “stuff”); .
mysqli – This function will initiate a new connection using MySQli extension. This function will take four arguments.
(a) hostname where the MySQl database is running.
(b) MySQl username to connect.
(c) Password for the MySQl user.
(d) MySQl database to connect.

(ii) Connect from PHP MySQL PDO extension:
PDO_MySQL drive implements the PDO interface provided by PHP to connect from your PHP program to MySQL database.
Create the following MySQl_pdo.php file under our Apache document Root:
<?php
$conn = new PDO (“mysql: host = localhost: dbname=stuff”, “root”, “DBPass”) ;
$conn set Attribute (PDO:: ATTR_ERRMODE, PDO:: ERRMODE_EXCEPTION);

• New PDO – This will create a new PDO object. The Three arguments are.
(a) MySQl connect string.
(b) MySQl username to connect.
(c) Password for the MySQl user.

(iii) Connect from PHP using legacy mysql_function:
Use this method only if we are using an older version of PHP and cannot upgrade it to the new version.
Create the following mysql legacy. php file under the Apache (isset($_POST [‘reg_user’]))

<?php
$Conn = mysql_connect (‘localhost’, ‘root’, ‘DB Pass’ ) ; mysql_select_db (“stuff”) ;
mysql_connect function takes three arguments.
(a) Hostname where the MySQL database is running.
(b) MySQl username to connect.
(c) Password for the MySQl user.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 38.
Explain MySQLi Queries with examples.
Answer:
mysqli_query( ) is the function that executes the MySQLi queries.
Squery is the SQL query to be executed. Slinkidentifier is optional, it can be used to pass in the server connection link.
MySQLi function can be used to execute the following query type:
• INSERT, SELECT, UPDATE, DELETE.
Syntax: <?php
mysqli_query(“Connection Object”, “Query”)
where,
Mysqli_query – is the function that executes the SQL queries.
Query – is the SQL query to be executed.
Connection object – used to pass in the server link.
Eg:
$con = mysqli_connect (“localhost”, “my_user”, “my_password”, “student_DB”) ;
$sql = “select student_name, student_age FROM .
student”; MySQli_query (Scon, $sql)

Question 39.
Create simple student Login Form to validate username and password using PHP and MySQL (Server side validation).
Answer:
Server, php
<?php
Session_start();
// initializing variables
Susername = ” “;
Serrors = Array();
//connect to the database
$db = mysqli_connect (‘localhost’, ‘root’, ‘ ‘registration’);
//Register user
if (isset ($_POST [‘reg_user’])}
{
//receive all input values from the form
$username = mysqli_real_escape_string($db, $POST[‘username’]);
$password_1 = mysqli_real_escape_string($db, $POST[‘password_1’]);
$password_2 = mysqli_real_escape_string($db, $POST[‘password_2’]);
//form validation
if(empty($username))
{array_push($errors, “username is required”);}
if(empty($password_1))
{array_push($errors, “password is required”);}
if ($password_1 = $password_2) ‘
{array_push ($errors, “The two passwords do not match”) ; }
//First check the database to make sure
$user_check_query = “SELECT*FROM users WHERE
username = ‘$username’ ;
$result = mysqli_query($db, $user_check_query);
$user = mysqli_fetch_assoc($result);
if ($user)
{
if($user)[‘user name’]=== $username)
{
{array_push($errors, “Username already exists”);
}
}
//Register user if there are no errors in the form
if (count ($errors)==0)
{
$password = md5($password_1);
$query = “INSERT INTO users (username, password) VALUES( ‘$username’, ‘$password’) “;
mysqli_query($db, $query);
$_SESSION[‘username’] = $username
$_SESSI0N[‘success’] = “we are now logged in”;
header(‘location:index.PhP’ ) ;
}
}
//. . .

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 40.
Create simple student registration form to insert students details like Student Name, username and password etc. Using PHP and MySQL (Server side validation).
Answer:
//student Registration form code-server side program using php .
<?php
require(‘db.php’);
//Form submited Insert values
If(isset($_REQUEST[‘username’]))
{
$username = mysqli_real_escape_string($con, $username);
$email = stripslashes ($_REQUEST[’email’]);
$email = mysqli_real_escape_string($con, $email);
$password = stripslashes($_REQUEST[‘Password’]);
$password = mysqli_real_escape_string($con, $password);
$Dob = date(“y-m-d H:i:s”);
$query = insert into ‘student’ (username, password email, Dob)
Values (’$username’ , ‘” .md5 ($password) , ‘$email’, ($dob’)
Sresult = mysqli_query($con, $query); if($result)
{
echo “<div class form’>
<h3> you are registered successfully </h3>
<br/>click here to <a href = ‘login.php’> Login</a> </div>”;
}
}
else
{
?>
<div class = “form”>
<h1> Registration </h1>
<form name = “registration” action = ” ” method = “POST”>
<input type = “text” name = “username” placeholder = “Username” required/>
<input type> = “email” name = “email” placeholder = “Email” required/>
<input type = “password” name = “password” placeholder = “password” required/>
<input type = “DOB” name = “Date of Birth” Placeholder = “DOB” required/>
<input type = “submit” name = “submit” value = “Register”/>
</form>
</div>
<?php
}
?>
</body>
</html>

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Choose the correct answer:

Question 1.
Which one of the following databases has PHP supported almost since the beginning?
(a) Oracle
(b) SQL
(c) SQL+
(d) MYSQL
Answer:
(d) MYSQL

Question 2.
If there is no error, then what will the error () method return?
(a) true
(b) false
(c) empty string
(d) zero
Answer:
(c) empty string

Question 3.
Which method returns the error code generated from the execution of the last MySQL function?
(a) ermo( )
(d) ermumber( )
(c) erromo( )
(d) erromumber( )
Answer:
(a) ermo( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 4.
Which one of the following statements can be used to select the database?
(a) $mysqli = select db (‘databasename’);
(b) mysqli = select_db (‘databasename’);
(c) mysqli → select db (‘databasename’);
(d) $mysqli → select_db (‘databasename’);
Answer:
(d) $mysqli → select_db (‘databasename’);

Question 5.
Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
(a) connect_error( )
(b) connect_ermo( )
(c) mysqli_connect_errono( )
(d) mysqli_connect_error( )
Answer:
(c) mysqli_connect_errono( )

Question 6.
Which method retrieves each row from the prepared statement result and . assigns the fields to the bound results?
(a) get_row( )
(b) fetch_row( )
(c) fetch( )
(d) row( )
Answer:
(c) fetch( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 7.
Which one of the method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
(a) num_rows( )
(b) affected_rows( )
(c) changed_rows( )
(d) new_row( )
Answer:
(b) affected_rows( )

Question 8.
Which of the methods are used to manage result sets using both associative and indexed arrays?
(a) get_array( ) and get_row( )
(b) get_array( ) and get_column( )
(c) fetch_array( ) and fetch_row( )
(d) fetch_array( ) and fetch_column( )
Answer:
(c) fetch_array( ) and fetch_row( )

Question 9.
Which one of the following methods recuperates any memory consumed by a result set?
(a) destroy( )
(b) remover( )
(c) alloc( )
(d) free( )
Answer:
(d) free( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 10.
Which one of the following methods is responsible for sending the query to the database?
(a) query( )
(b) sendquery( )
(c) sendquery( )
(d) querysend( )
Answer:
(a) query( )

Question 11.
The updated MySQL extension released with PH5 is typically referred to as:
(a) MYSQL
(b) MYSQLe
(c) MYSQli
(d) MYSAly
Answer:
(c) MYSQli

Question 12.
Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
(a) extension = php_mysqli.dll
(b) extension = mysql.dll
(c) extension = php mysqli.dl
(d) extension = mysqli.dl
Answer:
(a) extension = php_mysqli.dll

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 13.
In which version of PHP was MySQL Native Driver (mysqlnd) introduced?
(a) PHP 5.0
(b) PHP 5.1
(c) PHP 5.2
(d) PHP 5.3
Answer:
(d) PHP 5.3

Question 14.
Which one of the following statements should be used to include a file?
(a) #include ‘filename’;
(b) include ‘filename’;
(c) @include ‘filename’;
(d) include;
Answer:
(b) include ‘filename’;

Question 15.
Which version of MySQL introduced the prepared statements?
(a) MySQL 4.0
(b) MySQL 4.1
(c) MySQL 4.2
(d) MySQL 4.3
Answer:
(b) MySQL 4.1

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 16.
Which of the following methods is used to execute the statement after the parameters have been bound?
(a) bind_param( )
(b) bind_result( )
(c) bound_param( )
(d) boundresult( )
Answer:
(a) bind_param( )

Question 17.
Which one of the following methods is used to recuperating prepared statements resources?
(a) end ( )
(b) finish( )
(c) final( )
(d) close ( )
Answer:
(d) close ( )

Question 18.
Which method rolls back the present transaction?
(a) commit( )
(b) undo( )
(c) back( )
(d) rollback( )
Answer:
(d) rollback( )

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 19.
What will be the output of the following PHP code?
<?php
$on_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
echo $on_e/$tw_o + $thre_e/$fou_r;
?>
(a) 0.75
(b) 0.05
(c) 1.25
(d) Error
Answer:
(c) 1.25

Question 20.
What will be the output of the following PHP code?
<?php
echo $red;
?>
(a) 0
(b) No output
(c) red
(d) error
Answer:
(b) No output

Question 21.
What will be the output of the following PHP code?
<?php
$four4 = 4;
$three = 3;
$two = 2;
echo $four4 + $three3/$two2 -1;
?>
(a) 4.5
(b) 7
(c) 3.5
(d) Error
Answer:
(a) 4.5

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 22.
Match the following:

(A) local host  (i) database name
(B) Sdbname  (ii) servername
(C) MySQli__query  (iii) web framework
(D) symphony  (iv) function

(a) (A) – (ii); (B) – (i); (C) – (iv); (D) – (iii)
(b) (A) – (ii); (B) – (iii); (C) – (iv); (D) – (i)
(c) (A) – (iii); (B) – (ii); (C) – (i); (D) – (iv)
(d) (A) – (iii); (B) – (i); (C) – (iv); (D) – (ii)
Answer:
(a) (A) – (ii); (B) – (i); (C) – (iv); (D) – (iii)

Question 23.
Choose the incorrect pair:
(a) MSSQLSERVER – ROMS
(b) DELETE – SQL
(c) MySQLi – PHP
(d) MySQL – Client side web
Answer:
(d) MySQL – Client side web

Question 24.
Choose the correct pair:
(a) HIPHOP’s – PHP Version
(b) HPHP’s – MySQL
(c) PRADO – function
(d) Cake PHP – website
Answer:
(a) HIPHOP’s – PHP Version

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 25.
Choose the incorrect statement:
(a) SQL is a domain-specific language used in programming and design.
(b) MySQL is an open-source relational database management system.
(c) A database is an organized collection of software.
(d) A query is a request for data or information from a database table.
Answer:
(c) A database is an organized collection of software.

Question 26.
Choose the correct statement:
(a) PHP is open source and scripting language.
(b) PHP is a client-side scripting language.
(c) PHP cannot embed easily with HTML.
(d) Web servers cannot support PHP scripting language.
Answer:
(a) PHP is open source and scripting language.

Question 27.
Assertion (A):
The combination of PHP and MySQL has become very popular server side web scripting language in Internet.
Reason (R):
Seventy percentage of website has been built by PHP and MySQL.
(a) Both A and R are true, and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, But R is false.
(d) A is false, But R is true.
Answer:
(a) Both A and R are true, and R is the correct explanation for A.

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 28.
Assertion (A):
Facebook technology stack consists of application written in many language, including PHP and many others.
Reason (R):
Facebook has manythings built in PHP, Actually its not the real PHP, Facebook have written alternative version of PHP that is HiPHOP’s HPHP’c which help to convert PHP code into C++.
(a) Both A and R are true, and R is the correct explanation for A
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, But R is false.
(d) A is false, But R is true.
Answer:
(a) Both A and R are true, and R is the correct explanation for A

Question 29.
Pick the odd one out.
(a) Facebook
(b) Twitter
(c) Linkedin
(d) CakePHP
Answer:
(d) CakePHP

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 30.
Pick the odd one out.
(a) SQL
(b) MySQL
(c) Queries
(d) DB2
Answer:
(c) Queries

Question 31.
Which one of the following statements instantiates the mysqli class?
(a) mysqli = new mysqli( )
(b) Smysqli = new mysqli( )
(c) $mysqli->new.mysqli( )
(d) mysqli->new.mysqli( )
Answer:
(b) Smysqli = new mysqli( )

Question 32.
Which one is correct way, we can retrieve the data in the result set of MySQL using PHP?
(a) mysql_fetch_row
(b) mysql_fetch_array
(c) mysql_fetch_object
(d) All the above
Answer:
(d) All the above

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 33.
How Can we Create a Database Using PHP and MySQL?
(a) mysqli_create_db(“Database Name”)
(b) mysqli_create_db(“Data”)
(c) create_db(“Database Name”)
(d) create_db(“Data”)
Answer:
(a) mysqli_create_db(“Database Name”)

Question 34.
Which is the correct function to execute the SQL queries in PHP ?
(a) mysqli_query(“Connection Object”, “SQL Query”)
(b) query(“Connection Object”, “SQL Query”)
(c) mysql_query(“Connection Object”, “SQL Query”)
(d) mysql_query(“SQL Query”)
Answer:
(a) mysqli_query(“Connection Object”, “SQL Query”)

Question 35.
Which is the correct function Closing Connection in PHP ?
(a) mysqli_close(“Connection Object”);
(b) close(“Connection Object”);
(c) mysql_close(“Connection Object”);
(d) mysqli_close(“Database Object”);
Answer:
(a) mysqli_close(“Connection Object”);

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 36.
Which is the correct function to establish Connection in PHP?
(a) MySQli_connect(“ServerName”, “User Name”, “Password”, “DBName”);
(b) connect(“Server Name”, “User Name”, “Password”, “DB Name”);
(c) MySQl_connect(“Server Name”, “User Name”, “Password”, “DB Name”);
(d) mysqli connect (“Database Object”);
Answer:
(a) MySQli_connect(“ServerName”, “User Name”, “Password”, “DBName”);

Question 37.
Which is the not a correct MySQL Function in PHP ?
(a) MySQli_connect() Function
(b) MySQli_close() Function
(c) MySQli_select_data() Function
(d) MySQli_affected_rows() Function
Answer:
(c) MySQli_select_data() Function

Question 38.
How many parameter are required for MySQLi connect function in PHP?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(c) 4

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 39.
How many parameter are required for MySQLi query function in PHP?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

Question 40.
How many parameter are required for MySQLi Close function in PHP?
(a) 1
(b) 2
(c) 3
(d) 5
Answer:
(a) 1

Samacheer Kalvi TN State Board 12th Computer Applications Important Questions Chapter 9 Connecting PHP and MYSQL

Question 41.
Which version of PHP supports MySQLi factions ?
(a) Version 2.0
(b) Version 3.0
(c) Version 4.0
(d) Version 5.0
Answer:
(d) Version 5.0

TN Board 12th Computer Applications Important Questions