0% found this document useful (0 votes)
3 views

PHP_Assignment-5

The document is an assignment for a PHP and MySQL course at Ganpat University, consisting of multiple-choice questions and long-answer questions related to sessions, cookies, and MySQL functions. It covers topics such as session management, cookie handling, and basic database operations in PHP. The assignment aims to assess students' understanding of these concepts through both theoretical and practical questions.

Uploaded by

jayeshpatel8144
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PHP_Assignment-5

The document is an assignment for a PHP and MySQL course at Ganpat University, consisting of multiple-choice questions and long-answer questions related to sessions, cookies, and MySQL functions. It covers topics such as session management, cookie handling, and basic database operations in PHP. The assignment aims to assess students' understanding of these concepts through both theoretical and practical questions.

Uploaded by

jayeshpatel8144
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GANPAT UNIVERSITY, KHERVA

BSPP/IOT, COMPUTER ENGINEERING DEPARTMENT


ASSIGNMENT-5
PHP & MySQL (1IT2402)
MCQ
1. Which one of the following is the very first task executed by a session
enabled page?
A) Delete the previous session
B) Start a new session
C) Check whether a valid session exists
D) Handle the session

2. How many ways can a session data be stored?


A) 3 B) 4 C) 5 D) 6

3. Which one of the following function is used to start a session?


A) start_session() B) session_start() C) session_begin() D) begin_session()

4. Which function is used to erase all session variables stored in the current
session?
A) session_destroy()
B) session_change()
C) session_remove()
D) session_unset()

5. What will the function session_id() return is no parameter is passed?


a) Current Session Identification Number
b) Previous Session Identification Number
c) Last Session Identification Number
d) Error

6. Which one of the following statements should you use to set the session
username to Nachi?
a) $SESSION[‘username’] = “Nachi”;
b) $_SESSION[‘username’] = “Nachi”;
c) session_start(“nachi”);
d) $SESSION_START[“username”] = “Nachi”;

7. The session_start() function must appear _________


a) after the html tag
b) after the body tag
c) before the body tag
d) before the html tag

8. Which of the following function is used to save a cookie in the user's


computer?
a) savecookie()
b) createcookie()
c) create_cookie()
d) setcookie()

9. How can we retrieve information from the specified cookie?


A) Using getcookie() function
B) Using readcookie() function
C) Using $_COOKIE superglobal variable
D) None of the above

10. Which of the following function is used to check the cookie is set or not?
A) iscookie_set()
B) is_cookie_set()
C) isset()
D) is_set()

11. Is it true that the setcookie() function must be called before the HTML tag
in the PHP script?
A) Yes
B) No

12.What is the default expire time of a cookie, if not specified in the setcookie()
function?
A) 1 day
B) 1 week
C) 8 hours
D) When session expires
13.Can we modify the already created cookie in PHP?
A) Yes
B) No

14.Which of the following function is used to delete a cookie?


A) setcookie()
B) delete_cookie()
C) deletecookie()
D) removecookie()

15.Can we set multiple values in a single cookie in PHP?


A) Yes
B) No

16.Which one of the following databases has PHP supported almost since the
beginning?
a) Oracle Database
b) SQL
c) SQL+
d) MySQL
17. The updated MySQL extension released with PHP 5 is typically referred to
as _______________
a) MySQL
b) mysql
c) mysqli
d) mysqly
18. Which one of the following statements is used to create a table?
a) CREATE TABLE table_name (column_name column_type);
b) CREATE table_name (column_type column_name);
c) CREATE table_name (column_name column_type);
d) CREATE TABLE table_name (column_type column_name);
19. Which one of the following statements instantiates the mysqli class?
a) mysqli = new mysqli()
b) $mysqli = new mysqli()
c) $mysqli->new.mysqli()
d) mysqli->new.mysqli()
20. 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');
21. Which one of the following statements should be used to include a file?
a) #include ‘filename’;
b) include ‘filename’;
c) @include ‘filename’;
d) #include <filename>;
22. Which one of the following methods is responsible for sending the query to the
database?
a) query()
b) send_query()
c) sendquery()
d) mysqli_query()
23. Which one of the following 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) mysqli_affected_rows()

Long Questions

1. Define cookies. Explain how to create and delete cookies.


2. Explain session in PHP. OR Describe how to open and destroy session
and how to unset all session variables.
3. Differentiate between Cookie and Session.
4. Explain features of MySQL.
5. Write PHP script to insert, delete and update records in table of MySQL
database.
6. Describe following functions of MySQL database using PHP with
example.
a) Mysql_connect() e) mysql_fetch_array()
b) Mysql_select_db() f) mysql_num_row()
c) Mysql_query() g) mysql_error()
d) Mysql_fetch_row() h) mysql_close()

You might also like