Online php and mysql interview Questions with answers-- Asked at different competitive exams
Free Online test your knowledge on php and mysql programming exams. Each questions immediate answer or explanation given below, just click View answer button and also have option of Hide Answer button to hide answer. In this given upto 100+ questions and shows answer or explanation under of each question.
Here all the questions and answers, most asked in different competitive exams and shows answers accordingly.
Q61. What is the difference between CHAR and VARCHAR data types?
Answer:
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.
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.
Q62. How can we encrypt and decrypt a data present in a mysql table using mysql?
Answer:
AES_ENCRYPT() and AES_DECRYPT()
Q63. Will comparison of string “10” and integer 11 work in PHP?
Answer:
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
Q64. How can I load data from a text file into a table?
Answer:
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
Great tool but you need to make sure that:
a) Data must be delimited
b) Data fields must match table columns correctly
Q65. How can we know the number of days between two given dates using MySQL?
Answer:
Use DATEDIFF()
SELECT DATEDIFF(NOW(),’2006-07-01′);
SELECT DATEDIFF(NOW(),’2006-07-01′);
Q66.What is the difference between GROUP BY and ORDER BY in SQL?
Answer:
To sort a result, use an ORDER BY clause.
The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary table to discover groups and apply aggregate functions (if any).
ORDER BY [col1],[col2],…[coln]; Tells DBMS according to what columns it should sort the result. If two rows will hawe the same value in col1 it will try to sort them accordingto col2 and so on.
GROUP BY [col1],[col2],…[coln]; Tells DBMS to group (aggregate) results with samevalue of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average.
The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary table to discover groups and apply aggregate functions (if any).
ORDER BY [col1],[col2],…[coln]; Tells DBMS according to what columns it should sort the result. If two rows will hawe the same value in col1 it will try to sort them accordingto col2 and so on.
GROUP BY [col1],[col2],…[coln]; Tells DBMS to group (aggregate) results with samevalue of column col1. You can use COUNT(col1), SUM(col1), AVG(col1) with it, if you want to count all items in group, sum all values or view average.
Q67. What is meant by MIME?
Answer1:
MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. However browsers also uses MIME standard to transmit files. MIME has a header which is added to a beginning of the data. When browser sees such header it shows the data as it would be a file
(for example image)
Some examples of MIME types:
audio/x-ms-wmp
image/png
aplication/x-shockwave-flash
Answer2: Multipurpose Internet Mail Extensions.
WWW’s ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them.
This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types.
(for example image)
Some examples of MIME types:
audio/x-ms-wmp
image/png
aplication/x-shockwave-flash
Answer2: Multipurpose Internet Mail Extensions.
WWW’s ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them.
This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types.
Q68. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
Answer1:
mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array.
mysql_fetch_object() -> Fetch a result row as an object.
mysql_fetch_row() -> Fetch a result set as a regular array().
Answer2: The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1], etc.), while the latter returns a the results an array containing both numeric and associative keys ($row[‘name’], $row[’email’], etc.). mysql_fetch_object() returns an object ($row->name, $row->email, etc.).
mysql_fetch_object() -> Fetch a result row as an object.
mysql_fetch_row() -> Fetch a result set as a regular array().
Answer2: The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1], etc.), while the latter returns a the results an array containing both numeric and associative keys ($row[‘name’], $row[’email’], etc.). mysql_fetch_object() returns an object ($row->name, $row->email, etc.).
Q69. If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?
Answer:
Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser.
Q70. What are the MySQL database files stored in system ?
Answer:
Data is stored in name.myd
Table structure is stored in name.frm
Index is stored in name.myi
Table structure is stored in name.frm
Index is stored in name.myi
0 Comments:
Post a Comment