DEVFYI - Developer Resource - FYI

PHP Interview Questions and Answers

Part:   1  2  3  4  5  6  7  8  9   10  11  12  13  14  15  16  17  18  19  20 

(Continued from previous part...)

Give the syntax of REVOKE commands?

The generic syntax for revoke is as following

REVOKE [rights] on [database] FROM [username@hostname]

Now rights can be:
a) ALL privilages
b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc.

We can grant rights on all databse by usingh *.* or some specific database by database.* or a specific table by database.table_name.


Answer the questions with the following assumption

The structure of table view buyers is as follows:

+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| user_pri_id | int(15)     |      | PRI | NULL    | auto_increment |
| userid      | varchar(10) | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+

The value of user_pri_id of the last row is 2345. What will happen in the following conditions?

Condition 1: Delete all the rows and insert another row. What is the starting value for this auto incremented field user_pri_id?

Condition 2: Delete the last row (having the field value 2345) and insert another row. What is the value for this auto incremented field user_pri_id?

In both conditions, the value of this auto incremented field user_pri_id is 2346.


What is the difference between CHAR and VARCHAR data types?

CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, "Hello!" will be stored as "Hello! " in CHAR(10) column.

VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, "Hello!" will be stored as "Hello!" in VARCHAR(10) column.

How can we encrypt and decrypt a data present in a mysql table using mysql?

AES_ENCRYPT() and AES_DECRYPT()


Will comparison of string "10" and integer 11 work in PHP?

Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.


What is the functionality of MD5 function in PHP?

string md5(string)

It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number.


How can I load data from a text file into a table?

The MySQL provides a LOAD DATA INFILE command. You can load data from a file. Great tool but you need to make sure that:

a) Data must be delimited
b) Data fields must match table columns correctly


How can we know the number of days between two given dates using MySQL?

Use DATEDIFF()

SELECT DATEDIFF(NOW(),'2006-07-01');


How can we change the name of a column of a table?

This will change the name of column:

ALTER TABLE table_name CHANGE old_colm_name new_colm_name

(Continued on next part...)

Part:   1  2  3  4  5  6  7  8  9   10  11  12  13  14  15  16  17  18  19  20 

PHP Interview Questions and Answers