0% found this document useful (0 votes)
393 views17 pages

Best PHP Mysql Interview Questions and Answers by Ashutoh Kr. Azad

The document provides an overview of PHP-MySQL interview questions and answers. It states that the author has been compiling questions to make a PDF version for offline use. The first set of questions includes what are the differences between GET and POST methods in form submitting and how form data is transmitted. Other questions cover retrieving data from MySQL result sets using PHP and creating a database in PHP and MySQL.

Uploaded by

Ashutosh Kr Azad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
393 views17 pages

Best PHP Mysql Interview Questions and Answers by Ashutoh Kr. Azad

The document provides an overview of PHP-MySQL interview questions and answers. It states that the author has been compiling questions to make a PDF version for offline use. The first set of questions includes what are the differences between GET and POST methods in form submitting and how form data is transmitted. Other questions cover retrieving data from MySQL result sets using PHP and creating a database in PHP and MySQL.

Uploaded by

Ashutosh Kr Azad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

PHP-MySQL Interview Question

Last few days I have been working to compile a question and answer set for PHPMyS L interview questions! "here are roughly #$% questions and i will be adding more as days to come! "hese questions and answers are compiled from different online resources! I am planning to make it a P&' version so that people download it and go through it offline! I hope i will be able to finish it soon! NB: If you want to add any question, please add it to the o!!ents se tion" I want to !a#e it a $i% repository" Here is the first set of &' Questions and answer"
Q:1 A:1

What are the differences between Get and post methods in form submitting. give the case where we can use get and we can use post methods?

When to use GET or P !T


The HTML 2.0 specification says, in section Form Submission (and the HTML 4.0 specification repeats this with minor sty istic chan!es"# $%&f the processin! of a form is idempotent (i.e. it has no astin! obser'ab e effect on the state of the wor d", then the form method shou d be ()T. Many database searches ha'e no 'isib e side*effects and ma+e idea app ications of ,uery forms. $ $%&f the ser'ice associated with the processin! of a form has side effects (for e-amp e, modification of a database or subscription to a ser'ice", the method shou d be ./ST.

"ow the form data is transmitted?


,uotation from the HTML 4.0 specification $% &f the method is 0!et1 * *, the user a!ent ta+es the 'a ue of action, appends a 2 to it, then appends the form data set, encoded usin! the app ication3-*www*form*ur encoded content type. The user a!ent then tra'erses the in+ to this 45&. &n this scenario, form data are restricted to 6S7&& codes. $% &f the method is 0post1 $, the user a!ent conducts an HTT. post transaction usin! the 'a ue of the action attribute and a messa!e created accordin! to the content type specified by the enctype attribute.

Quote from #G$ %AQ


First y, the the HTT. protoco specifies differin! usa!es for the two methods. ()T re,uests shou d a ways be idempotent on the ser'er. This means that whereas one ()T re,uest mi!ht (rare y" chan!e some state on the Ser'er, two or more identica re,uests wi ha'e no further effect. This is a theoretica point which is a so !ood ad'ice in practice. &f a user hits 0re oad1 on his3her browser, an

identica re,uest wi be sent to the ser'er, potentia y resu tin! in two identica database or !uestboo+ entries, counter increments, etc. 8rowsers may re oad a ()T 45L automatica y, particu ar y if cachein! is disab ed (as is usua y the case with 7(& output", but wi typica y prompt the user before re*submittin! a ./ST re,uest. This means you9re far ess i+e y to !et inad'ertent y*repeated entries from ./ST. ()T is (in theory" the preferred method for idempotent operations, such as ,ueryin! a database, thou!h it matters itt e if you9re usin! a form. There is a further practica constraint that many systems ha'e bui t*in imits to the en!th of a ()T re,uest they can hand e# when the tota si:e of a re,uest (45L;params" approaches or e-ceeds <=b, you are we *ad'ised to use ./ST in any case. & wou d prefer ./ST when & don9t want the status to be chan!e when user resubmits. 6nd ()T when it does not matter. Q:& A:& Who is the father of P"P and e'p(ain the changes in P"P versions? 5asmus Lerdorf is +nown as the father of .H...H.3F& 2.0 is an ear y and no on!er supported 'ersion of .H.. .H. > is the successor to .H.3F& 2.0 and is a ot nicer. .H. 4 is the current !eneration of .H., which uses the ?end en!ine under the hood. .H. @ uses ?end en!ine 2 which, amon! other thin!s, offers many additiona //. features "ow can we submit a form without a submit button? The main idea behind this is to use Aa'a script submit(" function in order to submit the form without e-p icit y c ic+in! any submit button. Bou can attach the document.formname.submit(" method to onc ic+, onchan!e e'ents of different inputs and perform the form submission. you can e'en bui t a timer function where you can automatica y submit the form after -- seconds once the oadin! is done (can be seen in on ine test sites". $n how man+ wa+s we can retrieve the data in the resu(t set of ,+!Q- using P"P? Bou can do it by 4 Cays<. mys, DfetchDrow. 2. mys, DfetchDarray >. mys, DfetchDobEect 4. mys, DfetchDassoc What is the difference between m+s/(0fetch0ob1ect and m+s/(0fetch0arra+? m+s/(0fetch0ob1ect23 is simi ar tom+s/(0fetch0arra+23, with one difference * an obEect is returned, instead of an array. &ndirect y, that means that you can on y access the data by the fie d names, and not by their offsets (numbers are i e!a property names". What is the difference between 5message and 55message?

Q:) A:)

Q:* A:*

Q:. A:.

Q:4

A:4

&t is a c assic e-amp e of .H.9s 'ariab e 'ariab es. ta+e the fo owin! e-amp e.Fmessa!e G 0Mi:an1HFFmessa!e G 0is a moderator of .H.Iperts.1H Fmessa!e is a simp e .H. 'ariab e that we are used to. 8ut the FFmessa!e is not a 'ery fami iar face. &t creates a 'ariab e name Fmi:an with the 'a ue 0is a moderator of .H.Iperts.1 assi!ned. brea+ it i+e thisFJFmessa!eK G% Fmi:anSometimes it is con'enient to be ab e to ha'e 'ariab e 'ariab e names. That is, a 'ariab e name which can be set and used dynamica y. "ow can we e'tract string 7abc.com 7 from a string 7http:88info9abc.com: using regu(ar e'pression of P"P? pre!Dmatch(13Lhttp#M3M3.;N(.;"F31,9http#33infoNabc.com9,Ffound"H echo FfoundO<PH "ow can we create a database using P"P and ,+!Q-? Ce can create MySQL database with the use of mys, DcreateDdb(0Ratabase Same1" What are the differences between re/uire and inc(ude= inc(ude0once and re/uire0once? The inc(ude23 statement inc udes and e'a uates the specified fi e.The documentation be ow a so app ies to re/uire23. The two constructs are identica in e'ery way e-cept how they hand e fai ure. inc(ude23 produces a Carnin! whi e re/uire23 resu ts in a Fata )rror. &n other words, use re/uire23 if you want a missin! fi e to ha t processin! of the pa!e. inc(ude23 does not beha'e this way, the script wi continue re!ard ess. The inc(ude0once23 statement inc udes and e'a uates the specified fi e durin! the e-ecution of the script. This is a beha'ior simi ar to the inc(ude23 statement, with the on y difference bein! that if the code from a fi e has a ready been inc uded, it wi not be inc uded a!ain. 6s the name su!!ests, it wi be inc uded Eust once.inc(ude0once23 shou d be used in cases where the same fi e mi!ht be inc uded and e'a uated more than once durin! a particu ar e-ecution of a script, and you want to be sure that it is inc uded e-act y once to a'oid prob ems with function redefinitions, 'ariab e 'a ue reassi!nments, etc. re/uire0once23 shou d be used in cases where the same fi e mi!ht be inc uded and e'a uated more than once durin! a particu ar e-ecution of a script, and you want to be sure that it is inc uded e-act y once to a'oid prob ems with function redefinitions, 'ariab e 'a ue reassi!nments, etc.

Q:6 A:6

Q:; A:;

Q:< A:<

Q:1> #an we use inc(ude 2?abc.P"P?3 two times in a P"P page @maAeit.P"P?? A:1> Bes we can use inc ude(" more than one time in any pa!e thou!h it is not a 'ery !ood practice. Q:11 What are the different tab(es present in ,+!Q-= which t+pe of tab(e is generated when we are creating a tab(e in the fo((owing s+nta': create tab(e emp(o+ee 2eno int2&3=ename varchar21>33 ? A:11 Tota @ types of tab es we can create <. My&S6M 2. Heap >. Mer!e 4. &SS/ R8 @. &S6M My&S6M is the defau t stora!e en!ine as of MySQL >.2> and as a resu t if we do not specify the tab e name e-p icit y it wi be assi!ned to the defau t en!ine. Q:1& %unctions in $,AP= P P) ABC -CAP? A:1& Bou can find these specific information in .H. Manua . Q:1) "ow can $ e'ecute a P"P script using command (ine? A:1) 6s of 'ersion 4.>.0, .H. supports a new S6.& type (Ser'er 6pp ication .ro!rammin! &nterface" named 7L& which means 7ommand Line &nterface. Aust run the .H. 7L& (7ommand Line &nterface" pro!ram and pro'ide the .H. script fi e name as the command ine ar!ument. For e-amp e, 0php myScript.php1, assumin! 0php1 is the command to in'o+e the 7L& pro!ram. 8e aware that if your .H. script was written for the Ceb 7(& interface, it may not e-ecute proper y in command ine en'ironment. Q:1* !uppose +our Dend engine supports the mode E? ?F Then how can u configure +our P"P Dend engine to support E?P"P ?F mode ? A:1* &n php.ini fi e# set short0open0tagGon to ma+e .H. support Q:1. !hopping cart on(ine va(idation i.e. how can we configure Pa+pa(= etc.? A:1. Ce can find the detai documentation about different paypa inte!ration process at the fo owin! site

.ay.a .H. !CH : http:88www.pa+pa(dev.org


Q:14 What is meant b+ n(&br23? A:14 &nserts HTML ine brea+s (T85 3%" before a new ines in a strin! strin! n 2br (strin!"H 5eturns strin! with 1 inserted before a new ines. For e-amp e# echo n 2br(1!od b essMn you1" wi output 0!od b ess Tbr 3% you1 to your browser.

Q:16 Craw the architecture of Dend engine? A:16 The ?end )n!ine is the interna compi er and runtime en!ine used by .H.4. Re'e oped by ?ee' Suras+i and 6ndi (utmans, the ?end )n!ine is an abbre'iation of their names. &n the ear y days of .H.4, it wor+ed as fo ows#

The .H. script was oaded by the ?end )n!ine and compi ed into ?end opcode. /pcodes, short for operation codes, are ow e'e binary instructions. Then the opcode was e-ecuted and the HTML !enerated sent to the c ient. The opcode was f ushed from memory after e-ecution.Today, there are a mu titude of products and techni,ues to he p you speed up this process. &n the fo owin! dia!ram, we show the how modern .H. scripts wor+H a the shaded bo-es are optiona .

.H. Scripts are oaded into memory and compi ed into ?end opcodes. Q:1; What are the current versions of apache= P"P= and ,+!Q-? A:1; 6s of February, 200U the current 'ersions are.H.# [email protected].< MySQL# MySQL @.2 6pache# 6pache 2.2.4Sote# 'isit www.php.net, http#33de'.mys, .com3down oads3mys, 3, www.apache.or! to !et current 'ersions. Q:1< What are the reasons for se(ecting (amp 2-inu'= apache= ,+!Q-= P"P3 instead of combination of other software programs= servers and operating s+stems?

A:1< 6 of those are open source resource. Security of Linu- is 'ery 'ery more than windows. 6pache is a better ser'er that &&S both in functiona ity and security. MySQL is wor d most popu ar open source database. .H. is more faster that asp or any other scriptin! an!ua!e. Q:&> "ow can we encr+pt and decr+pt a data present in a ,+!Q- tab(e using ,+!Q-? A:&> 6)SD)S75B.T (" and 6)SDR)75B.T (" Q:&1 "ow can we encr+pt the username and password using P"P? A:&1 The functions in this section perform encryption and decryption, and compression and uncompression#

en ryption ()S*)+,-."/0 )+,1&)/0 &)S*)+,-.P"/0 )+,-.P"/0 M&$/0 P(SS21-&/0 SH(/0 or SH(#/0 +ot available

de ryption ()S*&),-.P"/0 &),1&)/0 &)S*&),-.P"/0 +ot available +ot available +ot available +ot available 3+,1MP-)SS)&*L)+4"H/0

1L&*P(SS21-&/0 +ot available

Q:&& What are the features and advantages of ob1ectIoriented programming? A:&& /ne of the main ad'anta!es of // pro!rammin! is its ease of modificationH obEects can easi y be modified and added to a system there by reducin! maintenance costs. // pro!rammin! is a so considered to be better at mode in! the rea wor d than is procedura pro!rammin!. &t a ows for more comp icated and f e-ib e interactions. // systems are a so easier for non*technica personne to understand and easier for them to participate in the maintenance and enhancement of a system because it appea s to natura human co!nition patterns. For some systems, an // approach can speed de'e opment time since many obEects are standard across systems and can be reused. 7omponents that mana!e dates, shippin!, shoppin! carts, etc. can be purchased and easi y modified for a specific system Q:&) What are the differences between procedureIoriented (anguages and ob1ectIoriented (anguages? A:&) Traditiona pro!rammin! has the fo owin! characteristics#Functions are written se,uentia y, so that a chan!e in pro!rammin! can affect any code that fo ows it. &f a function is used mu tip e times in a system (i.e., a piece of code that mana!es the date", it is often simp y cut and pasted into each pro!ram (i.e., a chan!e o!, order function, fu fi ment system, etc". &f a date chan!e is needed (i.e., B2= when the code needed to be chan!ed to hand e four numerica di!its instead of two", a these pieces of code must be found, modified, and tested. 7ode (se,uences of computer instructions" and data (information on which the instructions operates on" are +ept separate. Mu tip e sets of code can access and modify one set of data. /ne set of code may re y on data in mu tip e p aces. Mu tip e sets of code and data are re,uired to wor+

to!ether. 7han!es made to any of the code sets and data sets can cause prob ems throu!h out the system./bEect*/riented pro!rammin! ta+es a radica y different approach#7ode and data are mer!ed into one indi'isib e item $ an obEect (the term 0component1 has a so been used to describe an obEect." 6n obEect is an abstraction of a set of rea *wor d thin!s (for e-amp e, an obEect may be created around 0date1" The obEect wou d contain a information and functiona ity for that thin! (6 date obEect it may contain abe s i+e Aanuary, February, Tuesday, Cednesday. &t may contain functiona ity that mana!es eap years, determines if it is a business day or a ho iday, etc., See Fi!. <". &dea y, information about a particu ar thin! shou d reside in on y one p ace in a system. The information within an obEect is encapsu ated (or hidden" from the rest of the system. 6 system is composed of mu tip e obEects (i.e., date function, reports, order processin!, etc., See Fi! 2". Chen one obEect needs information from another obEect, a re,uest is sent as+in! for specific information. (for e-amp e, a report obEect may need to +now what today9s date is and wi send a re,uest to the date obEect" These re,uests are ca ed messa!es and each obEect has an interface that mana!es messa!es. // pro!rammin! an!ua!es inc ude features such as 0c ass1, 0instance1, 0inheritance1, and 0po ymorphism1 that increase the power and f e-ibi ity of an obEect. Q:&* What is the use of friend function? A:&* Sometimes a function is best shared amon! a number of different c asses. Such functions can be dec ared either as member functions of one c ass or as ! oba functions. &n either case they can be set to be friends of other c asses, by usin! a friend specifier in the c ass that is admittin! them. Such functions can use a attributes of the c ass which names them as a friend, as if they were themse 'es members of that c ass. 6 friend dec aration is essentia y a prototype for a member function, but instead of re,uirin! an imp ementation with the name of that c ass attached by the doub e co on synta-, a ! oba function or member function of another c ass pro'ides the match. Q:&. What are the differences between pub(ic= private= protected= static= transient= fina( and vo(ati(e? A:&. Pub(ic: .ub ic dec ared items can be accessed e'erywhere. Protected: .rotected imits access to inherited and parent c asses (and to the c ass that defines the item". Private: .ri'ate imits 'isibi ity on y to the c ass that defines the item. !tatic: 6 static 'ariab e e-ists on y in a oca function scope, but it does not ose its 'a ue when pro!ram e-ecution ea'es this scope. %ina(: Fina +eyword pre'ents chi d c asses from o'erridin! a method by prefi-in! the definition with fina . &f the c ass itse f is bein! defined fina then it cannot be e-tended. transient: 6 transient 'ariab e is a 'ariab e that may not be seria i:ed. vo(ati(e: a 'ariab e that mi!ht be concurrent y modified by mu tip e threads shou d be dec ared 'o ati e. Variab es dec ared to be 'o ati e wi not be optimi:ed by the compi er because their 'a ue can chan!e at any time. Q:&4 What are the different t+pes of errors in P"P? A:&4 Three are three types of errors#<. Sotices# These are tri'ia , non*critica errors that .H. encounters whi e e-ecutin! a script * for e-amp e, accessin! a 'ariab e that has not yet been defined. 8y defau t, such errors are not disp ayed to the user at a * a thou!h, as you wi see, you can chan!e this defau t beha'ior.2. Carnin!s# These are more serious errors *

for e-amp e, attemptin! to inc ude(" a fi e which does not e-ist. 8y defau t, these errors are disp ayed to the user, but they do not resu t in script termination.>. Fata errors# These are critica errors * for e-amp e, instantiatin! an obEect of a non*e-istent c ass, or ca in! a non*e-istent function. These errors cause the immediate termination of the script, and .H.9s defau t beha'ior is to disp ay them to the user when they ta+e p ace. Q:&6 What is the functiona(it+ of the function strstr and stristr? A:&6 strstr# 5eturns part of haystack strin! from the first occurrence of needle to the end of haystack.&f needle is not found, returns FALSE. &f needle is not a strin!, it is con'erted to an inte!er and app ied as the ordina 'a ue of a character. This function is case*sensiti'e. For case*insensiti'e searches, use stristr23. Q:&; What are the differences between P"P ) and P"P * and P"P .? A:&; . ease read the re ease notes at http#33www.php.net. Q:&< "ow can we convert asp pages to P"P pages? A:&< there are ots of too s a'ai ab e for asp to .H. con'ersion. you can search (oo! e for that. the best one is a'ai ab e athttp#33asp2php.na+en.cc.3 Q:)> What is the functiona(it+ of the function htm(entities? A:)> 7on'ert a app icab e characters to HTML entities This function is identica to htm specia chars(" in a ways, e-cept with htm entities(", a characters which ha'e HTML character entity e,ui'a ents are trans ated into these entities. Q:)1 "ow can we get second of the current time using date function? A:)1 Fsecond G date(1s1"H Q:)& "ow can we convert the time Jones using P"P? A:)&

By using date_default_timezone_get and date_default_timezone_set function on PHP 5.1.0 < !"! ## $isco%e& '"at (am in )o*yo &elates to on t"e East +oast of t"e ,S ## Set t"e default timezone to )o*yo timedate_default_timezone_set./Asia#)o*yo/01 ## 2o' gene&ate t"e timestam! fo& t"at !a&ticula& timezone3

on 4an 1st3 5000 6stam! 7 m*time.(3 03 03 13 13 500001 ## 2o' set t"e timezone 8ac* to ,S#Easte&n date_default_timezone_set./,S#Easte&n/01 ## 9ut!ut t"e date in a standa&d fo&mat .:F+115;03 t"is 'ill !&int## F&i3 ;1 $ec 1<<< 1(-00-00 ES) ec"o /<!=/3 date.$A)E_:F+115;3 6stam!0 3/<#!=/1 =
Q:)) What is meant b+ ur(encode and ur(docode? A:)) 45Lencode returns a strin! in which a non*a phanumeric characters e-cept >_. ha'e been rep aced with a percent (?" si!n fo owed by two he- di!its and spaces encoded as p us ( @" si!ns. &t is encoded the same way that the posted data from a CCC form is encoded, that is the same way as in a!!lication#A>'''>fo&m>u&lencoded media type. ur decode decodes any ?## encodin! in the !i'en strin!. Q:)* What is the difference between the functions un(inA and unset? A:)* un in+(" de etes the !i'en fi e from the fi e system. unset(" ma+es a 'ariab e undefined. Q:). "ow can we register the variab(es into a session? A:). FDS)SS&/SO9name9P G 0Mi:an1H Q:)4 "ow can we get the properties 2siJe= t+pe= width= height3 of an image using P"P image functions? A:)4 To To To To +now +now +now +now the the the the &ma!e type use e-ifDima!etype (" function &ma!e si:e use !etima!esi:e (" function ima!e width use ima!es- (" function ima!e hei!ht use ima!esy(" function t

Q:)6 "ow can we get the browser properties using P"P? A:)6 8y usin!

6_SE:BE:C/H))P_,SE:_ADE2)/E %a&ia8le.
Q:); What is the ma'imum siJe of a fi(e that can be up(oaded using P"P and how can we change this? A:); 8y defau t the ma-imum si:e is 2M8. and we can chan!e the fo owin! setup at php.iniup oadDma-Dfi esi:e G 2M Q:)< "ow can we increase the e'ecution time of a P"P script? A:)< by chan!in! the fo owin! setup at php.inima-De-ecutionDtime G >0 H Ma-imum e-ecution time of each script, in seconds Q:*> "ow can we taAe a bacAup of a ,+!Q- tab(e and how can we restore it. ?

A:*> To bac+up# 867=4. T68L) tb DnameO,tb DnameWP T/ X3path3to3bac+up3directory9 5)ST/5) T68L) tb DnameO,tb DnameWP F5/M X3path3to3bac+up3directory9mys, dump# Rumpin! Tab e Structure and Rata4ti ity to dump a database or a co ection of database for bac+up or for transferrin! the data to another SQL ser'er (not necessari y a MySQL ser'er". The dump wi contain SQL statements to create the tab e and3or popu ate the tab e. *t, $no*create*info Ron9t write tab e creation information (the 75)6T) T68L) statement". *d, $no*data Ron9t write any row information for the tab e. This is 'ery usefu if you Eust want to !et a dump of the structure for a tab eY Q:*1 "ow can we optimiJe or increase the speed of a ,+!Q- se(ect /uer+? A:*1

first of a instead of usin! se ect Z from tab e<, use se ect co umn<, co umn2, co umn>.. from tab e< Loo+ for the opportunity to introduce inde- in the tab e you are ,ueryin!. use imit +eyword if you are oo+in! for any specific number of rows from the resu t set.

Q:*& "ow man+ wa+s can we get the va(ue of current session id? A:*& sessionDid(" returns the session id for the current session. Q:*) "ow can we destro+ the session= how can we unset the variab(e of a session? A:*) sessionDunre!ister [ 4nre!ister a ! oba 'ariab e from the current session sessionDunset [ Free a session 'ariab es Q:** "ow can we destro+ the cooAie? A:** Set the coo+ie in past. Q:*. "ow man+ wa+s we can pass the variab(e through the navigation between the pages? A:*.

()T3QueryStrin! ./ST

Q:*4 What is the difference between ereg0rep(ace23 and eregi0rep(ace23? A:*4 ere!iDrep ace(" function is identica to ere!Drep ace(" e-cept that this i!nores case distinction when matchin! a phabetic characters.ere!iDrep ace(" function is identica to ere!Drep ace(" e-cept that this i!nores case distinction when matchin! a phabetic characters. Q:*6 What are the different functions in sorting an arra+? A:*6 Sort(", arsort(", asort(", +sort(", natsort(", natcasesort(",

rsort(", usort(", arrayDmu tisort(", and u+sort(". Q:*; "ow can we Anow the count8number of e(ements of an arra+? A:*; 2 ways a" si:eof(Furarray" This function is an a ias of count(" b" count(Furarray" Q:*< What is the P"P predefined variab(e that te((s the What t+pes of images that P"P supports? A:*< Thou!h i am not sure if this is wron! or not, Cith the e-if e-tension you are ab e to wor+ with ima!e meta data. Q:.> "ow can $ Anow that a variab(e is a number or not using a Kava!cript? A:.> boo isDnumeric ( mi-ed 'ar" 5eturns T54) if 'ar is a number or a numeric strin!, F6LS) otherwise.or use isSaS(mi-ed 'ar"The isSaS(" function is used to chec+ if a 'a ue is not a number. Q:.1 -ist out some too(s through which we can draw EIL diagrams for m+s/(. A:.1 7ase Studio Smart Rraw Q:.& "ow can $ retrieve va(ues from one database server and store them in other database server using P"P? A:.& we can a ways fetch from one database and rewrite to another. here is a nice so ution of it.Fdb< G mys, Dconnect(1host1,1user1,1pwd1" mys, Dse ectDdb(1db<\, Fdb<"H Fres< G mys, D,uery(1,uery1,Fdb<"HFdb2 G mys, Dconnect(1host1,1user1,1pwd1" mys, Dse ectDdb(1db2\, Fdb2"H Fres2 G mys, D,uery(1,uery1,Fdb2"H6t this point you can on y fetch records from you pre'ious 5esu tSet, i.e Fres< * 8ut you cannot e-ecute new ,uery in Fdb<, e'en if you supp y the in+ as because the in+ was o'erwritten by the new db.so at this point the fo owin! script wi fai Fres> G mys, D,uery(1,uery1,Fdb<"H 33this wi fai So how to so 'e that2 ta+e a oo+ be ow. Fdb< G mys, Dconnect(1host1,1user1,1pwd1" mys, Dse ectDdb(1db<\, Fdb<"H Fres< G mys, D,uery(1,uery1,Fdb<"H Fdb2 G mys, Dconnect(1host1,1user1,1pwd1, true" mys, Dse ectDdb(1db2\, Fdb2"H Fres2 G mys, D,uery(1,uery1,Fdb2"H So mys, Dconnect has another optiona boo ean parameter which indicates whether a in+ wi be created or not. as we connect to the Fdb2 with this optiona parameter set to Xtrue9, so both in+ wi remain i'e. now the fo owin! ,uery wi e-ecute successfu y. Fres> G mys, D,uery(1,uery1,Fdb<"H

Than+s !oes to Hasan and Hasin for this so ution. Q:.) -ist out the predefined c(asses in P"P? A:.) Rirectory std7 ass DD.H.D&ncomp eteD7 ass e-ception phpDuserDfi ter Q:.* "ow can $ maAe a script that can be biI(anguage 2supports Eng(ish= German3? A:.* Bou can maintain two separate an!ua!e fi e for each of the an!ua!e. a the abe s are putted in both an!ua!e fi es as 'ariab es and assi!n those 'ariab es in the .H. source. on runtime choose the re,uired an!ua!e option. Q:.. What are the difference between abstract c(ass and interface? A:.. 6bstract c ass# abstract c asses are the c ass where one or more methods are abstract but not necessari y a method has to be abstract. 6bstract methods are the methods, which are dec are in its c ass but not define. The definition of those methods must be in its e-tendin! c ass.&nterface# &nterfaces are one type of c ass where a the methods are abstract. That means a the methods on y dec ared but not defined. 6 the methods must be define by its imp emented c ass. Q:.4 "ow can we send mai( using Kava!cript? A:.4 Aa'aScript does not ha'e any networ+in! capabi ities as it is desi!ned to wor+ on c ient site. 6s a resu t we can not send mai s usin! Aa'aScript. 8ut we can ca the c ient side mai protoco mai(to 'ia Aa'aScript to prompt for an emai to send. this re,uires the c ient to appro'e it. Q:.6 "ow can we repair a ,+!Q- tab(e? A:.6 The synte- for repairin! a MySQL tab e is 5).6&5 T68L)S6M), OT68L)S6M), P, OQuic+P,O)-tendedP This command wi repair the tab e specified if the ,uic+ is !i'en the MySQL wi do a repair of on y the inde- tree if the e-tended is !i'en it wi create inde- row by row Q:.; What are the advantages of stored procedures= triggers= inde'es? A:.; 6 stored procedure is a set of SQL commands that can be compi ed and stored in the ser'er. /nce this has been done, c ients don9t need to +eep re*issuin! the entire ,uery but can refer to the stored procedure. This pro'ides better o'era performance because the ,uery has to be parsed on y once, and ess information needs to be sent between the ser'er and the c ient. Bou can a so raise the conceptua e'e by ha'in! ibraries of functions in the ser'er. Howe'er, stored procedures of course do increase the oad on the database ser'er system, as more of the wor+ is done on the ser'er side and ess on the c ient (app ication" side.Tri!!ers wi a so be imp emented. 6 tri!!er is effecti'e y a type of stored procedure, one that is in'o+ed when a particu ar e'ent occurs. For e-amp e, you can insta a stored procedure that is tri!!ered each time a record is de eted from a transaction tab e and that stored procedure automatica y de etes the correspondin! customer from a customer tab e when a his transactions are de eted.&nde-es are used to find rows with specific co umn 'a ues ,uic+ y.

Cithout an inde-, MySQL must be!in with the first row and then read throu!h the entire tab e to find the re e'ant rows. The ar!er the tab e, the more this costs. &f the tab e has an inde- for the co umns in ,uestion, MySQL can ,uic+ y determine the position to see+ to in the midd e of the data fi e without ha'in! to oo+ at a the data. &f a tab e has <,000 rows, this is at east <00 times faster than readin! se,uentia y. &f you need to access most of the rows, it is faster to read se,uentia y, because this minimi:es dis+ see+s. Q:.< What is the ma'imum (ength of a tab(e name= database name= and fie(dname in ,+!Q-? A:.< The fo owin! tab e describes the ma-imum en!th for each type of identifier.

Identifier

Ma(i!u! Len%th )$ytes* 56 56 56 8$$

&atabase 56 "able ,olumn Inde7 (lias

There are some restrictions on the characters that may appear in identifiers# Q:4> "ow man+ va(ues can the !ET function of ,+!Q- taAe? A:4> MySQL set can ta+e :ero or more 'a ues but at the ma-imum it can ta+e ]4 'a ues Q:41 What are the other commands to Anow the structure of tab(e using ,+!Q- commands e'cept e'p(ain command? A:41 describe Tab e*SameH Q:4& "ow man+ tab(es wi(( create when we create tab(e= what are the+? A:4& The X.frm9 fi e stores the tab e definition. The data fi e has a X.MBR9 (MBRata" e-tension. The inde- fi e has a X.MB&9 (MB&nde-" e-tension, Q:4) What is the purpose of the fo((owing fi(es having e'tensions 13 .frm &3 .m+d )3 .m+i? What do these fi(es contain? A:4) &n MyS, , the defau t tab e type is My&S6M. )ach My&S6M tab e is stored on dis+ in three fi es. The fi es ha'e names that be!in with the tab e name and ha'e an e-tension to indicate the fi e type. The X.frm9 fi e stores the tab e definition. The data fi e has a X.MBR9 (MBRata" e-tension. The inde- fi e has a X.MB&9 (MB&nde-" e-tension, Q:4* What is ma'imum siJe of a database in ,+!Q-? A:4* &f the operatin! system or fi esystem p aces a imit on the number of fi es in a directory, MySQL is bound by that constraint.The efficiency of the operatin! system in hand in! ar!e numbers of fi es in a directory can p ace a practica imit on the number of tab es

in a database. &f the time re,uired to open a fi e in the directory increases si!nificant y as the number of fi es increases, database performance can be ad'erse y affected. The amount of a'ai ab e dis+ space imits the number of tab es. MySQL >.22 had a 4(8 (4 !i!abyte" imit on tab e si:e. Cith the My&S6M stora!e en!ine in MySQL >.2>, the ma-imum tab e si:e was increased to ]@@>] terabytes (2@]U $ < bytes". Cith this ar!er a owed tab e si:e, the ma-imum effecti'e tab e si:e for MySQL databases is usua y determined by operatin! system constraints on fi e si:es, not by MySQL interna imits.The &nnoR8 stora!e en!ine maintains &nnoR8 tab es within a tab espace that can be created from se'era fi es. This a ows a tab e to e-ceed the ma-imum indi'idua fi e si:e. The tab espace can inc ude raw dis+ partitions, which a ows e-treme y ar!e tab es. The ma-imum tab espace si:e is ]4T8. The fo owin! tab e ists some e-amp es of operatin! system fi e*si:e imits. This is on y a rou!h !uide and is not intended to be definiti'e. For the most up*to*date information, be sure to chec+ the documentation specific to your operatin! system. /peratin! System Fi e*si:e LimitLinu- 2.2*&nte >2*bit 2(8 (LFS# 4(8" Linu- 2.4; (usin! e-t> fi esystem" 4T8 So aris ^3<0 <]T8 SetCare w3SSS fi esystem _T8 Cin>2 w3 F6T3F6T>2 2(834(8 Cin>2 w3 STFS 2T8 (possib y ar!er" Mac/S I w3 HFS; 2T8 Q:4. Give the s+nta' of Grant and LevoAe commands? A:4. The !eneric synta- for !rant is as fo owin! % (56ST Ori!htsP on Odatabase3sP T/ OusernameNhostnameP &R)ST&F&)R 8B OpasswordP now ri!hts can be a" 6 pri'i e!es b" combination of create, drop, se ect, insert, update and de ete etc.Ce can !rant ri!hts on a databse by usin! Z.Z or some specific database by database.Z or a specific tab e by database.tab eDname usernameNhotsname can be either usernameN oca host, usernameNhostname and usernameN` where hostname is any 'a id hostname and ` represents any name, the Z.Z any condition password is simp y the password of userThe !eneric synta- for re'o+e is as fo owin! % 5)V/=) Ori!htsP on Odatabase3sP F5/M OusernameNhostnameP now ri!hts can be as e-p ained abo'e a" 6 pri'i e!es b" combination of create, drop, se ect, insert, update and de ete etc. usernameNhotsname can be either usernameN oca host, usernameNhostname and usernameN` where hostname is any 'a id hostname and ` represents any name, the Z.Z any condition Q:44 E'p(ain Borma(iJation concept? A:44 The norma i:ation process in'o 'es !ettin! our data to conform to three pro!ressi'e norma forms, and a hi!her e'e of norma i:ation cannot be achie'ed unti the pre'ious e'e s ha'e been achie'ed (there are actua y fi'e norma forms, but the ast two are main y academic and wi not be discussed".First Sorma FormThe First Sorma Form (or <SF" in'o 'es remo'a of redundant data from hori:onta rows. Ce want to ensure that there is no dup ication of data in a !i'en row, and that e'ery co umn stores the east amount of information possib e (ma+in! the fie d atomic".Second Sorma FormChere the First Sorma Form dea s with redundancy of data across a hori:onta row, Second Sorma Form (or 2SF" dea s with redundancy of data in 'ertica co umns. 6s stated ear ier, the norma forms are pro!ressi'e, so to achie'e Second Sorma Form, your tab es must a ready

be in First Sorma Form.Third Sorma Form & ha'e a confession to ma+eH & do not often use Third Sorma Form. &n Third Sorma Form we are oo+in! for data in our tab es that is not fu y dependant on the primary +ey, but dependant on another 'a ue in the tab e Q:46 "ow can we find the number of rows in a tab(e using ,+!Q-? A:46 4se this for mys, %S)L)7T 7/4ST(Z" F5/M tab eDnameH Q:4; "ow can we find the number of rows in a resu(t set using P"P? A:4;

6&esult 7 mysFl_Fue&y.6sFl3 6d8_lin*01 6num_&o's 7 mysFl_num_&o's.6&esult01 ec"o G6num_&o's &o's foundH1

Q:4< "ow man+ wa+s we can we find the current date using ,+!Q-? A:4< S)L)7T 745R6T)("H 7455)STDR6T)(" G 745R6T)(" for time use S)L)7T 745T&M)("H 7455)STDT&M)(" G 745T&M)(" Q:6> What are the advantages and disadvantages of #ascading !t+(e !heets? A:6> )-terna Sty e Sheets6d'anta!es7an contro sty es for mu tip e documents at once. 7 asses can be created for use on mu tip e HTML e ement types in many documents. Se ector and !roupin! methods can be used to app y sty es under comp econte-tsRisad'anta!es6n e-tra down oad is re,uired to import sty e information for each document The renderin! of the document may be de ayed unti the e-terna sty e sheet is oaded 8ecomes s i!ht y unwie dy for sma ,uantities of sty e definitions)mbedded Sty e Sheets 6d'anta!es 7 asses can be created for use on mu tip e ta! types in the document. Se ector and !roupin! methods can be used to app y sty es under comp econte-ts. So additiona down oads necessary to recei'e sty e information Risad'anta!es This method can not contro sty es for mu tip e documents at once &n ine Sty es 6d'anta!es 4sefu for sma ,uantities of sty e definitions. 7an o'erride other sty e specification methods at the oca e'e so on y e-ceptions need to be isted in conEunction with other sty e methods Risad'anta!es Roes not distance sty e information from content (a main !oa of

S(ML3HTML". 7an not contro sty es for mu tip e documents at once. 6uthor can not create or contro c asses of e ements to contro mu tip e e ement types within the document. Se ector !roupin! methods can not be used to create comp e- e ement addressin! scenarios Q:61 What t+pe of inheritance that P"P supports? A:61 &n .H. an e-tended c ass is a ways dependent on a sin! e base c ass, that is, mu tip e inheritance is not supported. 7 asses are e-tended usin! the +eyword Xe-tends9. Q:6& What is the difference between Primar+ He+ and Mni/ue Ae+? A:6& .rimary =ey# 6 co umn in a tab e whose 'a ues uni,ue y identify the rows in the tab e. 6 primary +ey 'a ue cannot be S4LL. 4ni,ue =ey# 4ni,ue =eys are used to uni,ue y identify each row in the tab e. There can be one and on y one row for each uni,ue +ey 'a ue. So S4LL can be a uni,ue +ey.There can be on y one primary +ey for a tab e but there can be more than one uni,ue for a tab e. The structure of tab(e view bu+ers is as fo((ows: Q:6)

+ield user*pri*id userid

,ype int/#$0 varchar/#%0

Null .)S

-ey .efault /(tra P-I null auto*increment null

the 'a ue of userDpriDid the ast row ^^^ then Chat wi happen in the fo owin! conditions2 #ondition1# Re ete a the rows and insert another row then. Chat is the startin! 'a ue for this auto incremented fie d userDpriDid , #ondition&# Re ete the ast row(ha'in! the fie d 'a ue ^^^" and insert another row then. Chat is the 'a ue for this auto incremented fie d userDpriDid A:6) &n both cases et the 'a ue for auto increment fie d be n then ne-t row wi ha'e 'a ue n;< i.e. <000 Q:6* What are the advantages8disadvantages of ,+!Q- and P"P? A:6* 8oth of them are open source software (so free of cost", support cross p atform. php is faster then 6S. and AS.. Q:6. What is the difference between GL MP NO and LCEL NO in !/(?

A:6. /5R)5 8B Oco <P,Oco 2P,W,Oco nPH Te s R8MS accordin! to what co umns it shou d sort the resu t. &f two rows wi hawe the same 'a ue in co < it wi try to sort them accordin! to co 2 and so on.(5/4. 8B Oco <P,Oco 2P,W,Oco nPH Te s R8MS to !roup resu ts with same 'a ue of co umn co <. Bou can use 7/4ST(co <", S4M(co <", 6V((co <" with it, if you want to count a items in !roup, sum a 'a ues or 'iew a'era!e Q:64 What is the difference between char and varchar data t+pes? A:64 Set char to occupy n bytes and it wi ta+e n bytes e'en if u r storin! a 'a ue of n*m bytes

Set 'archar to occupy n bytes and it wi ta+e on y the re,uired space and wi not use the n bytes e!. name char(<@" wi waste <0 bytes if we store Xmi:an9, if each char ta+es a byte e!. name 'archar(<@" wi Eust use @ bytes if we store Xmi:an9, if each char ta+es a byte. rest <0 bytes wi be free. Q:66 What is the functiona(it+ of md. function in P"P? A:66 7a cu ate the md@ hash of a strin!. The hash is a >2*character he-adecima number. & use it to !enerate +eys which & use to identify users etc. &f & add random no techni,ues to it the md@ !enerated now wi be tota y different for the same strin! & am usin!. Q:6; "ow can $ (oad data from a te't fi(e into a tab(e? A:6; you can use L/6R R6T6 &SF&L) fi eDnameH synta- to oad data from a te-t fi e. but you ha'e to ma+e sure thata" data is de imited b" co umns and data matched correct y Q:6< "ow can we Anow the number of da+s between two given dates using ,+!Q-? A:6< S)L)7T R6T)R&FF(9200U*0>*0Ua,9200@*0<*0<a"H Q:;> "ow can we Anow the number of da+s between two given dates using P"P? A:;> Fdate< G date(9B*m*d9"H Fdate2 G X200]*0_*<@aH Fdays G (strtotime(Fdate<" * strtotime(Fdate2"" 3 (]0 Z ]0 Z 24"H

"his page has the following sub pages!

You might also like