Custom Search

Thursday, February 28, 2013

PHP WITH MYSQL QUESTION AND ANSWERS


41. What are the other commands to know the structure of table using mysql commandsexcept explain command?

Answer:describe table_name;

42. How many tables will create when we create table, what are they?

Answer:3 tables will create when we create table. They areThe `.frm' file stores the table definition.The data file has a `.MYD' (MYData) extension.The index file has a `.MYI' (MYIndex) extension,

43. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI.What these files contains?

Answer:In MySql, the default table type is MyISAM.Each MyISAM table is stored on disk in three files. The files have names that beginwith the table name and have an extension to indicate the file type.The `.frm' file stores the table definition.The data file has a `.MYD' (MYData) extension.
The index file has a `.MYI' (MYIndex) extension,


44. How can we find the number of rows in a table using mysql?

Answer:Use this for mysql>SELECT COUNT(*) FROM table_name;but if u r particular about no of rows with some special resultdo this>SELECT [colms],COUNT(*) FROM table_name [where u put conditions];

45. How can we find the number of rows in a result set using php?

Answer:for PHP$result = mysql_query($any_valid_sql, $database_link);$num_rows = mysql_num_rows($result);echo “$num_rows rows found”;

46. How many ways we can we find the current date using mysql?

Answer:SELECT CURDATE();CURRENT_DATE() = CURDATE()for time useSELECT CURTIME();CURRENT_TIME() = CURTIME()

47. What type of inheritance that php supports?

Answer:In PHP an extended class is always dependent on a single base class, that is, multipleinheritance is not supported. Classes are extended using the keyword 'extends'.Usage:
var$owner;functionset_owner($name) { $this->owner=$name;}}?>


48. What are the advantages/disadvantages of mysql and php?

Answer:Both of them are open source software (so free of cost), support cross platform.php is faster then ASP and JSP.


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

Answer:The mysql provides a LOAD DATA INFILE syntax. U can load data from a file.Gr8 tool but u need to make sure thata) data is delimitedb) u match the colms and data correctly
dont use w/out first learning the syntax

50. How can we know the number of days between two given dates using mysql?
Answer:select DIFFDATE( NOW(), ‘yyyy-mm-dd’ );

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

Answer:
 MySQL query to rename table: RENAME TABLE
tbl_name
TO
new_tbl_name

[,
tbl_name2
TO
new_tbl_name2
] ...or,
ALTER TABLE tableName CHANGE OldName newName.

52. How can we change the name and data type of a column of a table?

 Answer: ALTER [IGNORE] TABLE
tbl_name

alter_specification
[,
alter_specification
] | CHANGE [COLUMN]
old_col_name

column_definition

[FIRST|AFTER
col_name
]

53. What are the differences between drop a table and truncate a table?

Answer:Delete a Table or DatabaseTo delete a table (the table structure, attributes, andindexes will also be deleted).What if we only want to get rid of the data inside a table, and not the table itself?Use the TRUNCATE TABLE command (deletes only the data inside the table).

54. What is meant by MIME?

Answer:Multipurpose Internet Mail Extensions.WWW's ability to recognise and handle files of different types is largely dependenton the use of the MIME (Multipurpose Internet Mail Extensions) standard. Thestandard provides for a system of registration of file types with information aboutthe applications needed to process them. This information is incorporated into Webserver and browser software, and enables the automatic recognition and display of registered file types.

55. What is meant by PEAR in php?

Answer:PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:A structured library of open-sourced code for PHP usersA system for code distribution and package maintenanceA standard style for code written in PHPThe PHP Foundation Classes (PFC),The PHP Extension Community Library (PECL),A web site, mailing lists and download mirrors to support the PHP/PEARcommunityPEAR is a community-driven project with the PEAR Group as the governing body.The project has been founded by Stig S. Bakken in 1999 and quite a lot of peoplehave joined the project since then.http://pear.php.net/manual/en/introduction.php

 56. How can I load the dll’s dynamically?98. How many ways we can give the output to a browser?
Answer:HTML outputPHP, ASP, JSP, Servlet FunctionScript Language output FunctionDifferent Type of embedded Package to output to a browser

57. How can we know that a session is started or not?

Answer:a session starts by session_start()function.this session_start() is always declared in header portion.it always declares first.thenwe write session_register().

58. What is the default session time in php and how can I change it?

Answer:The default session time in php is until closing of browser

 59. What changes I have to done in php.ini file for file uploading?
Answer:Make the following Line uncomment like:; Whether to allow HTTP file uploads.file_uploads = On; Temporary directory for HTTP uploaded files (will use system default if not; specified).upload_tmp_dir = C:\apache2triad\temp; Maximum allowed size for uploaded files.upload_max_filesize = 2M

60. What are the differences between mysql_fetch_array(), mysql_fetch_object(),mysql_fetch_row()?

Answer:mysql_fetch_array-- Fetch a result row as an associative array, a numeric array, orboth.mysql_fetch_object( resource result )Returns an object with properties that correspond to the fetched row and moves theinternal data pointer ahead. Returns an object with properties that correspond tothe fetched row, or FALSE if there are no more rowsmysql_fetch_row()fetches one row of data from the result associated with thespecified result identifier. The row is returned as an array. Each result column isstored in an array offset, starting at offset 0.

61. Steps for the payment gateway processing?

Ans:An online payment gateway is the interface between your merchant account andyour Web site. The online payment gateway allows you to immediately verify creditcard transactions and authorize funds on a customer's credit card directly fromyour Web site. It then passes the transaction off to your merchant bank forprocessing, commonly referred to as transaction batching


62. List out different arguments in php header function?
Answer:
void
header
( string string [, bool replace [, int http_response_code]])


63. What is the difference between and And which can bepreferable?

Answer:If functionality is same but

64. What are the differences between php3 and php4 versions?

Answer:As has already been mentioned by many PHP4 has native support for sessionsand the much touted XML. While this makes PHP a competitor in theApplication server languages arena, there is another core aspect to PHP4. Itis faster.
PHP3 used to parse line by line, while PHP acts like a compiler. This alongwith the ZEND optimizer makes PHP4 almost always faster than PHP3.I'm not sure about support for COM, it has caught my attention only in PHP4.If it was present in PHP3 I was not aware of it.Plus PHP4 can run as an Apache module, again this could have come in thelate versions of PHP3.

65. What are the differences between include() and include_once()functions?

Answer: include_once() will use the specified file only once. include and require willuse the specified file as many time we want. If include_once() is used before withsame name, it can not done again

66. Explain mysql optimization?

Answer:Optimization is a complex task because ultimately it requires understanding of theentire system. Although it may be possible to perform some local optimizations withlittle knowledge of your system or application, the more optimal you want yoursystem to become, the more you will have to know about it. The most importantfactor in making a system fast is the basic design. You also need to know what kindsof things your system will be doing, and what your bottlenecks are.


67. What is the difference between Reply-to and Return-path in the headers of a mailfunction?

Answer:Reply-to: Reply-to is where to delivery the reply of the mail.Return-path: Return path is when there is a mail delivery failure occurs then whereto delivery the failure notification.


68. 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.
69. When are you supposed to use endif to end the conditional statement?
Answer: When the original if was followed by : and then the code block without braces.
70. Explain the ternary conditional operator in PHP?
Answer: Expression preceding the ? is evaluated, if it"s true, then the expression preceding the : is executed,
otherwise, the expression following : is executed.
71. How do I find out the number of parameters passed into function in PHP?
Answer: func_num_args() function returns the number of parameters/arguments passed to a function in PHP.
72. What"s the difference between accessing a class method via -> and via ::?
Answer: In PHP, :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.
73. Are objects passed by value or by reference?
Answer: Everything is passed by value. In PHP4 it's true, BUT in PHP5 absolutely not - all objects are passed by reference.
74. How do you call a constructor for a parent class?
Answer: parent::constructor($value)
75. What"s the special meaning of __sleep and __wakeup?
Answer: __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
76. Would you initialize your strings with single quotes or double quotes in PHP?
Answer: Since the data inside the single-quoted string is not parsed for variable substitution, it"s always a
better idea speed-wise to initialize a string with single quotes, unless you specifically need variable
substitution.
77. What"s the difference between htmlentities() and htmlspecialchars()?
Answer: htmlspecialchars only takes care of <, >, single quote ", double quote " and ampersand. htmlentities
translates all occurrences of character sequences that have different meaning in HTML.
78. What"s the difference between md5(), crc32() and sha1() crypto on PHP?
Answer: The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1()
returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.

79. What is a Session in PHP?

Answer

A PHP session is no different from a normal session. It can be used to store information on the server for future use. However this storage is temporary and is flushed out when the site is closed. Sessions can start by first creating a session id (unique) for each user.

Syntax : session_start()

80. How can we increase the execution time of a php script?

Answer:Set max_execution_time variable in php.ini file to your desired time in second.

 

No comments:

Post a Comment