Tuesday, July 15, 2008

PHP-Mysql Interview Questions

Q:1
How can we submit a form without a submit button?

A:1
The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you
can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).

Q:2
In how many ways we can retrieve the data in the result set of MySQL using PHP?

A:2
You can do it by 4 Ways
1. mysql_fetch_row.

2. mysql_fetch_array

3. mysql_fetch_object

4. mysql_fetch_assoc

Q:3
What is the difference between mysql_fetch_object and mysql_fetch_array?

A:3
mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

Q:4
What is the difference between $message and $$message?
A:4
It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan
with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.

Q:5
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?


A:5
preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);

echo $found[1];

Q:6
How can we create a database using PHP and MySQL?

A:6
We can create MySQL database with the use of

mysql_create_db(“Database Name”)

Q:7
What are the differences between require and include, include_once and require_once?

A:7
The include() statement includes and evaluates the specified file.The documentation below also applies to require(). The two constructs are identical in every way except how they handlefailure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missingfile to halt processing of the page.

include() does not behave this way, the script will continue regardless.

The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once()
should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.

Q:8
Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?

A:8
Yes we can use include() more than one time in any page though it is not a very good practice.



Q:9
What are the different tables present in MySQL, which type of table is generated when we are creating a table in the following syntax:
create table employee (eno int(2),ename varchar(10)) ?


A:9
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM

MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.

Q:10
How can we encrypt the username and password using PHP?
A:10
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption

AES_ENCRYT() AES_DECRYPT()

ENCODE() DECODE()

DES_ENCRYPT()   DES_DECRYPT()

ENCRYPT() Not available

MD5() Not available

OLD_PASSWORD() Not available

PASSWORD() Not available

SHA() or SHA1() Not available

Not available UNCOMPRESSED_LENGTH()


oDesk Certified Software Testing Engineer

21 comments:

vaasu said...

nice.. good and thanks

Sree said...

Its Really Nice if possible can u add the reaming QAS
Thanku so much
Sree

Avi said...

nice post dude.
keep going

dileswar said...

Thank u so much, for posting like good qa.I m looking forward to u r further update.

free tutorials said...

Hey thanks a lot for sharing useful interview questions..... which will be very helpful while attending the interviews.....
glad i found ur site...really a very helpful site.....
by the way check out my collection of php interview questions from here: php interview questions

varun s said...

nice.. good and thanks

mallorca said...

Hi

Tks very much for post:

I like it and hope that you continue posting.

Let me show other source that may be good for community.

Source: Sample interview questions

Best rgs
David

ranji said...

good information about php

Anonymous said...

nice

Anonymous said...

Thanks ...

car hire chennai said...

good information thanks for sharing it

shivsingh said...

how to show a user is online if it show then i close my browser then i will be online or not without logout?.........

shivsingh said...
This comment has been removed by a blog administrator.
shivsingh said...
This comment has been removed by a blog administrator.
avinash sahu said...

good collection bro.

Kinal Patel said...

Thank you so much i have lot of things from this interview question

Nitin Gautam said...
This comment has been removed by the author.
Nitin Gautam said...

nice post buddy.......but these questions are to be asked on fresher level also.........so could u provide somo more advance questions..........


I would be thankfull to u
Nitin

Anonymous said...

Nice tutorial.. very thanks for sharing this information

mallesh said...

thq u very much
i am new in php so it more help to me i can understand easily to this Q and A
thks&Regrads
Mallesh

mallesh said...

plz post more questions on advanced topic of php also it wil helpful to biginers and exp