logo
  • Home
  • Rank
  • Tests
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Contact

PHP Multiple Choice Questions | MCQs | Quiz

PHP Interview Questions and Answers
Practice PHP questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Basics - 1
•   Basics - 2
•   Basics - 3
•   Functions
•   PHP In-Built Functions
•   Arrays - 1
•   Arrays - 2
•   Arrays - 3
•   Arrays - 4
•   Arrays - 5
•   Object Oriented PHP - 1
•   Object Oriented PHP - 2
•   Advanced Object Oriented
•   Error Handling
•   Exception Handling
•   PHP Filter
•   Regular Expressions - 1
•   Regular Expressions - 2
•   File System & PHP
•   Date & Timestamp
•   Working with Dates
•   HTML Forms
•   User Authentication
•   Uploading Files with PHP
•   PHP Networking
•   Session Handling - 1
•   Session Handling - 2
•   Website Security
•   Preg Basics
•   Databases Working - 1
•   Databases Working - 2
•   Object Basics - 1
•   Object Basics - 2
•   Updating & Deleting Entries
•   Image Uploading Ability
•   Object Advanced Features1
•   Object Advanced Features2
•   Object Advanced Features3
•   Object Tools - 1
•   Object Tools - 2
•   Object & Design - 1
•   Object & Design - 2
•   Syntax - 1
•   Syntax - 2
•   Variables - 1
•   Variables - 2
•   Variables - 3
•   Variables - 4
•   Echo
•   Print
•   Constants
•   Operators - 1
•   Operators - 2
•   Operators - 3
•   Operators - 4
•   Operators - 5
•   If-Else-If - 1
•   If-Else-If - 2
•   If-Else-If - 3
•   Switch
•   While Loops - 1
•   While Loops - 2
•   For Loops - 1
•   For Loops - 2
•   For Loops - 3
•   Functions - 1
•   Functions - 2
•   Functions - 3
•   Functions - 4
•   Functions - 5
•   Functions - 6

PHP Tests

PHP Tests

Best Reference Books

PHP Books
« Prev Page
Next Page »

PHP Questions & Answers – Working with Databases-2

Posted on May 22, 2013 by Manish

This set of PHP Quiz focuses on “Working with Databases-2”.

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

Answer: b
Explanation: An example of this-

advertisement
  1. <?php
  2. #include 'mysql.connect.php';
  3. //begin database selection and queries.
  4. ?>

2. Which one of the following methods is responsible for sending the query to the database?
a) query()
b) send_query()
c) sendquery()
d) query_send()
View Answer

Answer: a
Explanation: Its prototype looks like-

class mysqli
{
	mixed query(string query [, int resultmode])
}

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

Answer: d
Explanation: Once this method is executed, the result set is no longer available.

4. 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()
View Answer

Answer: c
Explanation: Their prototype is as follows-

advertisement
calss mysqli_result
{
	mixed fetch_array ([int resulttype])
}
 
calss mysqli_result
{
	mixed fetch_row()
}

5. 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) new_rows()
View Answer

Answer: b
Explanation: The method num_rows() is only useful for determining the number of rows retrieved by a SELECT query. But to retrieve the number of rows affected by INSERT, UPDATE, or DELETE query, use affected_rows().

6. Which version of MySQL introduced the prepared statements?
a) MySQL 4.0
b) MySQL 4.1
c) MySQL 4.2
d) MySQL 4.3
View Answer

Answer: b
Explanation: When the query() method is looped repeatedly it comes at a cost of both overhead, because of the need to repeatedly parsing of the almost identical query for validity, and coding convenience, because of the need to repeatedly reconfigure the query using the new values for each iteration. To help resolve the issues incurred by repeatedly executed queries, MySQL introduced prepared statements.

7. 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) bound_result()
View Answer

Answer: a
Explanation: Once the statement has been prepared, it needs to be executed. Exactly when it’s executed depends upon whether you want to work with bound parameters or bound results. In the case of bound parameters, you’d execute the statement after the parameters have been bound with the bind_param() method.

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

Answer: d
Explanation: Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the close() method.

9. 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()
View Answer

Answer: c
Explanation: Its prototype follows:

advertisement
  1. class mysqli
  2. {
  3. boolean fetch()
  4. }

10. Which method rolls back the present transaction?
a) commit()
b) undo()
c) back()
d) rollback()
View Answer

Answer: d
Explanation: Its prototype follows:

class mysqli
{
boolean rollback()
}

Sanfoundry Global Education & Learning Series – PHP Programming.

To practice all areas of PHP for Quizzes, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.

« Prev Page - PHP Questions & Answers – Working with Databases-1
» Next Page - PHP Questions & Answers – Object Basics-1

« PHP Questions & Answers – Working with Databases-1
PHP Questions & Answers – Object Basics-1 »
advertisement

Deep Dive @ Sanfoundry:

  1. Terms of Service
  2. Java Programming Examples
  3. Simple Java Programs
  4. Java Programming Examples on Utility Classes
  5. Ruby Programming Questions and Answers
  6. Oracle Database Questions and Answers
  7. C# Questions and Answers
  8. Java Programming Examples on Classes
  9. Java Programming Examples on Exception Handling
  10. MySQL Database Questions and Answers
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below:
LinkedIn | Facebook | Twitter | Google+

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
Terms
Privacy Policy
Jobs
Bangalore Training
Online Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry. All Rights Reserved.