What a loaded question! Let’s narrow that down a bit and take it from the perspective of someone who wants to work from home and make money online in a home business. That will make it an easier question to answer.
Let’s assume you’ve never had a website, don’t know how to get a merchant account, don’t know html, and are pretty much stuck with being an expert on sending and receiving email.
What’s there for you to do online to make money? Lots, in fact! These days are not at all like a couple of years ago or even six months ago. If I only had all the opportunities to make money online when I started marketing!
Here is a list of things you can do with just a website and a hosting account today:
Sell affiliate products (products like reports, ebooks, hard goods of every conceivable make, model, size, shape and function, and much, much more). Sell services (do you know how big a business being a Virtual Assistant is these days? It’s quite amazing what you can do for people without ever meeting them face-to-face, anywhere in the world!) Online auctions (Ebay has made thousands and thousands of people full-time incomes from auctioning collectibles, antiques, and even brand new equipment and gadgets of all imaginable types. You name it, it has been sold on Ebay!) Membership sites: Know of any groups of people that would love to get insider information on virtually any topic? You could make money online with a membership site!
The list is a long one and one I am not prepared to detail here. You have found your way onto the net and if you have been surfing for very long at all you know it is a gigantic super shopping mall. Who to you think is making the most money online? Aside from big corporations, most of the web is made up of sites put up by little businesses people work from home.
I sell information and I love it. Most of the products I sell are other merchants’ products. I just drive traffic to my site, provide information, and point to relevant products related to the information I provide people looking for a way to make money online. I love helping people make their first few sales.
After that, they are always hooked and cannot do enough to learn everything there is to know about how to make money online. Many people I have worked with now have a couple to several websites selling everything from reports to hard goods that can be shipped direct to their customers. Most people start out to make money online as affiliates of certain products or authors. This is a great way to get your feet wet and learn what making money online is all about. People then either work to create their own products (which they get 100% of the profits from) or expand their website into other related niches.
Sunday, January 3, 2010
Monday, July 7, 2008
SAP ARCHITECTURE-SAP R/3 ARCHITECTURE
1. What assurance the integration of all application modules?
The R/3 basis system assurance the incorporation of all application modules. The R/3 basis s/w provides the run time setting for the R/3 applications ensures optimal integration, defines a stable architectural frame for system augmentation, and contains the administration tools for the entire system.One of the main tasks of the basis system is to guarantee the portability of the complete system.
2. What are the central crossing points of the R/3 system?
Presentation Interface.Database Interface.Operating system Interface.
3. Which interface controls what is shown on the p.c.?
Presentation Interface.
4. Which interface change SQL requirements in the SAP development system to those of the database?
Database Interface.
5. What is SAP dispatcher?
SAP dispatcher is the control manager that manages the resources for the R/3 applications.
6. What are the functions of dispatcher?
Equal allocation of transaction load to the work processes.Management of buffer areas in main memory.Integration of the presentation levels.Organization of communication activities.
7. What is a work process?
A work process is where individual dialog steps are in reality processed and the work is done. Each work process handles one type of request.
8. Name a range of work processes of R/3 system?
Dialog or Online (processes only one request at a time).Background (Started at a specific time)Update (primary or secondary)Enque (Lock mechanism).Spool (generated online or during back ground processing for printing).
9. Explain on the two services that are used to deal with communication.
Message Service: Used by the application servers to exchange short internal messages, all system communications.
Gateway Service: facilitate communication between R/3 and external applications using CPI-C protocol.
10. Which work process triggers database changes?
Update work process.
11. Define service (within R/3)?
A service is a process or group of processes that execute a specific system function and often provide an application-programming interface for other processes to call.
12. What are the roll and page areas?
Roll and page areas are SAP R/3 buffers used to store user contexts (process requests). The SAP dispatcher allocates process requests to work processes as they are queued in the roll and page areas.Paging area holds data from the application programs.Roll area holds data from preceding dialog steps and data that characterize the user.
13. What are the various layers in R/3 system?
Presentation Layer.Application Layer.Database Layer.
14. What are the phases of background processing?
Job Scheduling.Job Processing.Job Overview.
15. What components of the R/e system begin the start of background jobs at the specified time?
The batch scheduler begins the start of background job. The dispatcher then sends this request to an accessible background work process for processing.
16. Define Instance.
An instance is an administrative part in which components of an R/3 systems providing one or more services are assembled together. The services offered by an instance are ongoing and stopped at random. All components are parameterized using a joint instance profile. A central R/3 system consists of a single instance in which all-necessary SAP services are offered. Each instance uses separate buffer areas.
17. From hardware point of view, every information system can be divided into three task areas Presentation, Application Logic and Data Storage.The R/3 Basis software is highly suitable for use in multi-level client/server architectures.
18. What are R/3 Basis configurations?
A central system with centrally installed presentation software.Two-level client/server system with rolled out presentation software.Two-level client/server system. Presentation and Application run on the same computer.Three-level client/server system. Presentation, Application and database each run on separate computers.
19. What is a Service in SAP terminology?
A service implies to something offered by a s/w component.
20. What is Server in SAP terminology?
A component can consist of one process or a group and is then called the server for the respective service.
21. What is a client in SAP terminology?
A S/W component that uses the service (offered by a s/w component) is name a Client. At the same time these clients may also be servers for other services.
22.What is a SAP system?
The union of all s/w components that are allocated to the same databases is called as a SAP system.
23. What is the means of communications between R/3 and external applications?
The means of communication between R/2,R/3 and external applications is via the CPI-C handler or SAP Gateway, using the CPI-C Protocol.
24. What is the protocol used by SAP Gateway process?
The SAP Gateway process communicates with the clients based on the TCP/IP Protocol.
25. Expand CPI-C.Common Program Interface Communication.
26. What is a Spool request?
Spool requests are produce during dialog or background processing and placed in the spool database with information about the printer and print format. The real data is places in the Tem Se (Temporary Sequential objects).
27. What are special types of Log records?
V1 and V2. V1 must be processed before V2. But, we can have more than one V2 logs.
28. What are the categories of Update requests?
An update request can be separated into one primary (V1) and several Secondary update components (V2). Time-critical operations are placed in V1 component and those whose timing is less critical are placed in V2 components. If a V1 update fails, V2 components will not be processed.
29. Dialog work processes perform only one dialog step and then available for the next request.
30. Explain what a transaction in SAP terms.
In SAP terms, a transaction is series of logically connected dialog steps.
31. Explain how SAP GUI handles output screen for the user.
The SAP front-end s/w can either run on the similar computer or on different computers provided for that purpose. User terminal input is established by the SAP terminal program SAP GUI, converted to SAP proprietary format and sent to the SAP dispatcher. The dispatcher organizes the information exchange between the SAP GUIs and the work processes. The dispatcher first places the processing request in request queues, which it then processes. The dispatcher dispatches the requests one after another, to the accessible work process. The actual processing takes place in the work process. When processing is done, the product of a work process is returned via the dispatcher to the SAP GUI. The SAP GUI read the received data and generates the output screen for the user
SAP Basics
1. What is your present development going on?
A. Tell the present company what u r working. From how long are you working there
keep in mind the dates better write down separately where have u worked
2. What is your SAP skills?
3. What are your daily activities at your place?
A. We do monitoring for the servers like we go throughout the .codes
SM37 – Simple job selection, ST22 : ABAP dump analysis, SM21 – System Log
SM13 - we will check update status SM12 – Check any Obsolete lock entries
SP01 – Check any spool errors, Db02 – Check any critical table spaces
DB12 – We will check Database logs ST02 – check Tuning summary
ST04 – Check the performance of the Database
4. How do you rate yourself from 1-10?
A. 8 out of 10
5. Can u tell me about R/3 Architecture?
A.1 tier :- all processing jobs are performed on one server
2 tier :- Presentation layer carried on one part and Application and Databse Services are carried
one server
3 tier :- Separate servers are used for 3 tier like we can say using data from database server, several deifferent application servers can operate at the same time
what is u r system configuration?
A.OS – Windows NT-4.0 with Service pack 6a RAM – 2 GB , 1 GB – Network Interface Card
IE 5.0
what u r current patch level? And oracle version?
A Kernel 620 kernel patch number 1090 , Oracle version 8.1.5.0
what is meant by tablespace?
A. It is a container for database objects such as table and indexes.
what is meant by central instance?
A. It is an R/3 Instance which contains the message service and typically contains all r/3 services
what is meant by checkpoint?
make sure point is an event during which all the modified data block will written to the datafile by the database writer.
What is an extent :
Collection of oracle blocks
What is a segment
A. Collection of extents is a segment
how to create a data file?
A. Alter table table_name add datafile;
What is a Client?
A client is an independently accountable business unit.
Tell me the transaction code for creating an RFC
SM59
Local Cleint copy – SCCL Remote Client copy – scc9
how to analyze system logs and dumps? Through SM21 and ST22
Tell me the default users in sap
A. SAP *, DDIC , Earlywatch
what is meant by Data Archiving?
A. Removal of application data from the database is called Data Archiving
how to maintain system profiles?
A. We can edit profiles through RZ10 and maintain through RZ11
How do u maintain and create authorization?
through T.Code PFCG
What is a role?
A role is a container for transactions, reports
How do u create a profile
A. t code : su02
how do u do a transportation
A. Through t .code STMS
How do u create a transport request
A. through the t.code SE01
Can u configure TMS?
Say it is already configured and I can configure
How do u maintain Spool Administration?
through SPAD
What is a Spool Server ?
A. The application server in the r/3 system.
28. Do u take backups at your site ?
A. Yes . I take online daily and offline weekend
What is the dissimilarity between online and offline
Online – Database will be running but still we can take backups
Offline – Database will be down. I mean we shutdown the database through SAPDBA to take offline backup
29. What is kernel upgrade?
A. Process of replacing Operating system file with update versions of the same files
We download from service.sap.com the kernel files
Eg of some kernel files : - BRRESTORE, BRCONNECT,SAPSTART,SAPCAR
How do u uncar the kernel file
Example : Car –xvf brrestore.car
Tell me the path of kernel files
usr/sap/<>/sys/exe/run in the run folder we have the kernel files
30. What is purpose of support package?
A. purpose is like we can say to fix problems before they become problem
Where do u download the support package files
usr/sap/trans/eps/in
we apply support patchs by loggin into 000 client as recommended by SAP.
9 SAP Interview Questions asked during my Interview
1) What is internal recruitment ?
Internal recruitment is search for internal applicants. when you integrate with personal development, you can use profile match up which help to search for resources internally.
Also In recruitment it is represented by ‘P’ as Person and ‘AP” as external person.
2) What are problems generally faced while posting result to FICO […]
SAP-ABAP Interview Questions-1
1. How data is stored in cluster table?
Each field of cluster table behaves as tables which contains the no. of entries.
2. What are client dependant objects in abap/sap?
SAP Script layout, text element, and some DDIC objects.
3. On which even we can validate the input fields in module programs?
In PAI (Write field statement on field you want to validate, if you want to validate group of fields put in chain and End chain statement.)
4. In selection screen I have three fields, plant mat no and material group. If I input plant how do I get the mat no and material group based on plant dynamically?
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MATERIAL. CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’ to get material and material group for the plant.
5. How do you get output from IDOC?
Data in IDOc is stored in segments, the output from Idoc is obtained by reading the data stored in its respective segments.
6. When top of the page event is triggered?
After executing first write statement in start-of-selection event.
7. Can we create field without data element and how?
In SE11 one option is available above the fields strip. Data element/ direct type.
8. How do we debug sapscript?
Go to SE71 give lay set name , go to utilities select debugger mode on.
9. Which transaction code can I used to analyze the performance of ABAP program.
TCode AL21.
10. How can I copy a standard table to make my own z_table.
Go to transaction SE11. Then there is one option to copy table. Press that button. Enter the name of the standard table and in the Target table enter Z table name and press enter.
11. What is the use of ‘outerjoin’
Ans. With the use of outer join you can join the tables even there is no entry in all the tables used in the view. In case of inner join there should be an entry in al the tables use in the view.
12. When to use logical database?
Ans. Advantage of Logical databases: less coding s required to retrieve data compared to normal internal tables. Tables used LDB are in hierarchical structure.
13. What is the use of ‘table index’?
Ans .Index is used for faster access of data base tables.
14. What is the use of ‘FOR ALL ENTRIES’?
Ans. To avoid nested select statements we use SELECT FOR ALL ENTRIES statement. If there r more than 10000 records SELECT FOR ALL ENTRIES is used. Performance wise SELECT FOR ALL ENTRIES is better to use.
15. Can you set up background processing using CALL TRANSACTION?
Yes,Using No Screen Mode.
16. What are table buffers?
Table buffers reside locally on each application server in the system. The data of buffered tables can thus be accessed directly from the buffer of the application server. This avoids the time-consuming process of accessing the database. Buffering is useful if table needs to be accessed more no. of times in a program.
17. How do I set a flag for a field in any table?
Create a char field of length 1. for example field STAS-LKENZ is Deletion Indicator. It means that if the value in the field is ‘X’ then that record has been deleted.
18. Can I execute user exits? If yes, how?
Yes you can. after finding the user exit, you need to use, goto CMOD add ur user-exit to your project. Then activate the FM which you require. Now go into that function module there will be a Include program wit name ZX* . Double click on it, it will ask to create an object, answer it Yes and then write your code in it.
19. How do I find the output type of a table or a program?
Table TNAPR / NAST
Note: Above interview questions are same if your are looking for Sap Abap Interview Question, Sap Abap Interview Questions, Sap Bw Interview Questions, SAP Interview Question, Sap Interview Questions, Sap Pp Interview Questions, Sap R 3 Interview Questions, Abap Interview, Abap Interview Question and Abap Interview Questions.
1. What assurance the integration of all application modules?
The R/3 basis system assurance the incorporation of all application modules. The R/3 basis s/w provides the run time setting for the R/3 applications ensures optimal integration, defines a stable architectural frame for system augmentation, and contains the administration tools for the entire system.One of the main tasks of the basis system is to guarantee the portability of the complete system.
2. What are the central crossing points of the R/3 system?
Presentation Interface.Database Interface.Operating system Interface.
3. Which interface controls what is shown on the p.c.?
Presentation Interface.
4. Which interface change SQL requirements in the SAP development system to those of the database?
Database Interface.
5. What is SAP dispatcher?
SAP dispatcher is the control manager that manages the resources for the R/3 applications.
6. What are the functions of dispatcher?
Equal allocation of transaction load to the work processes.Management of buffer areas in main memory.Integration of the presentation levels.Organization of communication activities.
7. What is a work process?
A work process is where individual dialog steps are in reality processed and the work is done. Each work process handles one type of request.
8. Name a range of work processes of R/3 system?
Dialog or Online (processes only one request at a time).Background (Started at a specific time)Update (primary or secondary)Enque (Lock mechanism).Spool (generated online or during back ground processing for printing).
9. Explain on the two services that are used to deal with communication.
Message Service: Used by the application servers to exchange short internal messages, all system communications.
Gateway Service: facilitate communication between R/3 and external applications using CPI-C protocol.
10. Which work process triggers database changes?
Update work process.
11. Define service (within R/3)?
A service is a process or group of processes that execute a specific system function and often provide an application-programming interface for other processes to call.
12. What are the roll and page areas?
Roll and page areas are SAP R/3 buffers used to store user contexts (process requests). The SAP dispatcher allocates process requests to work processes as they are queued in the roll and page areas.Paging area holds data from the application programs.Roll area holds data from preceding dialog steps and data that characterize the user.
13. What are the various layers in R/3 system?
Presentation Layer.Application Layer.Database Layer.
14. What are the phases of background processing?
Job Scheduling.Job Processing.Job Overview.
15. What components of the R/e system begin the start of background jobs at the specified time?
The batch scheduler begins the start of background job. The dispatcher then sends this request to an accessible background work process for processing.
16. Define Instance.
An instance is an administrative part in which components of an R/3 systems providing one or more services are assembled together. The services offered by an instance are ongoing and stopped at random. All components are parameterized using a joint instance profile. A central R/3 system consists of a single instance in which all-necessary SAP services are offered. Each instance uses separate buffer areas.
17. From hardware point of view, every information system can be divided into three task areas Presentation, Application Logic and Data Storage.The R/3 Basis software is highly suitable for use in multi-level client/server architectures.
18. What are R/3 Basis configurations?
A central system with centrally installed presentation software.Two-level client/server system with rolled out presentation software.Two-level client/server system. Presentation and Application run on the same computer.Three-level client/server system. Presentation, Application and database each run on separate computers.
19. What is a Service in SAP terminology?
A service implies to something offered by a s/w component.
20. What is Server in SAP terminology?
A component can consist of one process or a group and is then called the server for the respective service.
21. What is a client in SAP terminology?
A S/W component that uses the service (offered by a s/w component) is name a Client. At the same time these clients may also be servers for other services.
22.What is a SAP system?
The union of all s/w components that are allocated to the same databases is called as a SAP system.
23. What is the means of communications between R/3 and external applications?
The means of communication between R/2,R/3 and external applications is via the CPI-C handler or SAP Gateway, using the CPI-C Protocol.
24. What is the protocol used by SAP Gateway process?
The SAP Gateway process communicates with the clients based on the TCP/IP Protocol.
25. Expand CPI-C.Common Program Interface Communication.
26. What is a Spool request?
Spool requests are produce during dialog or background processing and placed in the spool database with information about the printer and print format. The real data is places in the Tem Se (Temporary Sequential objects).
27. What are special types of Log records?
V1 and V2. V1 must be processed before V2. But, we can have more than one V2 logs.
28. What are the categories of Update requests?
An update request can be separated into one primary (V1) and several Secondary update components (V2). Time-critical operations are placed in V1 component and those whose timing is less critical are placed in V2 components. If a V1 update fails, V2 components will not be processed.
29. Dialog work processes perform only one dialog step and then available for the next request.
30. Explain what a transaction in SAP terms.
In SAP terms, a transaction is series of logically connected dialog steps.
31. Explain how SAP GUI handles output screen for the user.
The SAP front-end s/w can either run on the similar computer or on different computers provided for that purpose. User terminal input is established by the SAP terminal program SAP GUI, converted to SAP proprietary format and sent to the SAP dispatcher. The dispatcher organizes the information exchange between the SAP GUIs and the work processes. The dispatcher first places the processing request in request queues, which it then processes. The dispatcher dispatches the requests one after another, to the accessible work process. The actual processing takes place in the work process. When processing is done, the product of a work process is returned via the dispatcher to the SAP GUI. The SAP GUI read the received data and generates the output screen for the user
SAP Basics
1. What is your present development going on?
A. Tell the present company what u r working. From how long are you working there
keep in mind the dates better write down separately where have u worked
2. What is your SAP skills?
3. What are your daily activities at your place?
A. We do monitoring for the servers like we go throughout the .codes
SM37 – Simple job selection, ST22 : ABAP dump analysis, SM21 – System Log
SM13 - we will check update status SM12 – Check any Obsolete lock entries
SP01 – Check any spool errors, Db02 – Check any critical table spaces
DB12 – We will check Database logs ST02 – check Tuning summary
ST04 – Check the performance of the Database
4. How do you rate yourself from 1-10?
A. 8 out of 10
5. Can u tell me about R/3 Architecture?
A.1 tier :- all processing jobs are performed on one server
2 tier :- Presentation layer carried on one part and Application and Databse Services are carried
one server
3 tier :- Separate servers are used for 3 tier like we can say using data from database server, several deifferent application servers can operate at the same time
what is u r system configuration?
A.OS – Windows NT-4.0 with Service pack 6a RAM – 2 GB , 1 GB – Network Interface Card
IE 5.0
what u r current patch level? And oracle version?
A Kernel 620 kernel patch number 1090 , Oracle version 8.1.5.0
what is meant by tablespace?
A. It is a container for database objects such as table and indexes.
what is meant by central instance?
A. It is an R/3 Instance which contains the message service and typically contains all r/3 services
what is meant by checkpoint?
make sure point is an event during which all the modified data block will written to the datafile by the database writer.
What is an extent :
Collection of oracle blocks
What is a segment
A. Collection of extents is a segment
how to create a data file?
A. Alter table table_name add datafile;
What is a Client?
A client is an independently accountable business unit.
Tell me the transaction code for creating an RFC
SM59
Local Cleint copy – SCCL Remote Client copy – scc9
how to analyze system logs and dumps? Through SM21 and ST22
Tell me the default users in sap
A. SAP *, DDIC , Earlywatch
what is meant by Data Archiving?
A. Removal of application data from the database is called Data Archiving
how to maintain system profiles?
A. We can edit profiles through RZ10 and maintain through RZ11
How do u maintain and create authorization?
through T.Code PFCG
What is a role?
A role is a container for transactions, reports
How do u create a profile
A. t code : su02
how do u do a transportation
A. Through t .code STMS
How do u create a transport request
A. through the t.code SE01
Can u configure TMS?
Say it is already configured and I can configure
How do u maintain Spool Administration?
through SPAD
What is a Spool Server ?
A. The application server in the r/3 system.
28. Do u take backups at your site ?
A. Yes . I take online daily and offline weekend
What is the dissimilarity between online and offline
Online – Database will be running but still we can take backups
Offline – Database will be down. I mean we shutdown the database through SAPDBA to take offline backup
29. What is kernel upgrade?
A. Process of replacing Operating system file with update versions of the same files
We download from service.sap.com the kernel files
Eg of some kernel files : - BRRESTORE, BRCONNECT,SAPSTART,SAPCAR
How do u uncar the kernel file
Example : Car –xvf brrestore.car
Tell me the path of kernel files
usr/sap/<>/sys/exe/run in the run folder we have the kernel files
30. What is purpose of support package?
A. purpose is like we can say to fix problems before they become problem
Where do u download the support package files
usr/sap/trans/eps/in
we apply support patchs by loggin into 000 client as recommended by SAP.
9 SAP Interview Questions asked during my Interview
1) What is internal recruitment ?
Internal recruitment is search for internal applicants. when you integrate with personal development, you can use profile match up which help to search for resources internally.
Also In recruitment it is represented by ‘P’ as Person and ‘AP” as external person.
2) What are problems generally faced while posting result to FICO […]
SAP-ABAP Interview Questions-1
1. How data is stored in cluster table?
Each field of cluster table behaves as tables which contains the no. of entries.
2. What are client dependant objects in abap/sap?
SAP Script layout, text element, and some DDIC objects.
3. On which even we can validate the input fields in module programs?
In PAI (Write field statement on field you want to validate, if you want to validate group of fields put in chain and End chain statement.)
4. In selection screen I have three fields, plant mat no and material group. If I input plant how do I get the mat no and material group based on plant dynamically?
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MATERIAL. CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’ to get material and material group for the plant.
5. How do you get output from IDOC?
Data in IDOc is stored in segments, the output from Idoc is obtained by reading the data stored in its respective segments.
6. When top of the page event is triggered?
After executing first write statement in start-of-selection event.
7. Can we create field without data element and how?
In SE11 one option is available above the fields strip. Data element/ direct type.
8. How do we debug sapscript?
Go to SE71 give lay set name , go to utilities select debugger mode on.
9. Which transaction code can I used to analyze the performance of ABAP program.
TCode AL21.
10. How can I copy a standard table to make my own z_table.
Go to transaction SE11. Then there is one option to copy table. Press that button. Enter the name of the standard table and in the Target table enter Z table name and press enter.
11. What is the use of ‘outerjoin’
Ans. With the use of outer join you can join the tables even there is no entry in all the tables used in the view. In case of inner join there should be an entry in al the tables use in the view.
12. When to use logical database?
Ans. Advantage of Logical databases: less coding s required to retrieve data compared to normal internal tables. Tables used LDB are in hierarchical structure.
13. What is the use of ‘table index’?
Ans .Index is used for faster access of data base tables.
14. What is the use of ‘FOR ALL ENTRIES’?
Ans. To avoid nested select statements we use SELECT FOR ALL ENTRIES statement. If there r more than 10000 records SELECT FOR ALL ENTRIES is used. Performance wise SELECT FOR ALL ENTRIES is better to use.
15. Can you set up background processing using CALL TRANSACTION?
Yes,Using No Screen Mode.
16. What are table buffers?
Table buffers reside locally on each application server in the system. The data of buffered tables can thus be accessed directly from the buffer of the application server. This avoids the time-consuming process of accessing the database. Buffering is useful if table needs to be accessed more no. of times in a program.
17. How do I set a flag for a field in any table?
Create a char field of length 1. for example field STAS-LKENZ is Deletion Indicator. It means that if the value in the field is ‘X’ then that record has been deleted.
18. Can I execute user exits? If yes, how?
Yes you can. after finding the user exit, you need to use, goto CMOD add ur user-exit to your project. Then activate the FM which you require. Now go into that function module there will be a Include program wit name ZX* . Double click on it, it will ask to create an object, answer it Yes and then write your code in it.
19. How do I find the output type of a table or a program?
Table TNAPR / NAST
Note: Above interview questions are same if your are looking for Sap Abap Interview Question, Sap Abap Interview Questions, Sap Bw Interview Questions, SAP Interview Question, Sap Interview Questions, Sap Pp Interview Questions, Sap R 3 Interview Questions, Abap Interview, Abap Interview Question and Abap Interview Questions.
SAP Transactions -1
29. Can we state the next screen number with a variable (*Yes/No)?
- Yes
30. The field SY-DYNR refers to--------------
Number of the current screen.
31. What is dialog Module?
- A dialog Module is a callable sequence of screens that does not belong to a particular transaction. Dialog modules have their module pools, and can be called by any transaction.
32. The Syntax used to call a screen as dialog box (pop up)is---------
CALL SCREEN
STARTING AT
ENDING AT
33. What is “call mode”?
- In the ABAP/4 WORLD each stackable series of screens is a “call mode”, This is IMP because of the way u return from the given sequence .To finish a call mode and return to a suspended chain set the “next screen” to 0 and leave to it:
LEAVE TO SCREEN 0 or (SET SCREEN 0 and LEAVE SCREEN) .When u return to the suspended chain execution resumes with the statement directly following the original CALL SCREEN statement.The original sequence of screens in a transaction (that is , without having stacked any additional call modes),you returned from the transaction altogether.
34. The max number of calling modes stacked at one time is?
- NINE
35. What is LUW or Data base Transaction?
- A “LUW”(logical unit of work) is the span of time during which any database updates must be carry out in an “all or nothing” manner .Moreover they are all performed (committed),or they are all thrown away (rolled back).In the ABAP/4 world , LUWs and
- Transactions can have several meanings:
LUW (or “database LUW” or “database transaction”)
This is the set of updates finished by a database commit. A LUW lasts, at most, from one screen change to the next (because the SAP system triggers database commits automatically at every screen change).
36. What is SAP LUW or Update Transaction?
Update transaction (or “SAP LUW”)
This is a set of updates terminated by an ABAP/4 commit. A SAP LUW may last much longer than a database LUW, since most update processing extends over multiple transaction screens. The programmer terminates an update transaction by issuing a COMMIT WORK statement.
37. What occur if only one of the commands SET SCREEN and LEAVE SCREEN is used with no using the other?
If we use SET SCREEN without LEAVE SCREEN, the program finishes processing for the present screen before branching to. If we use LEAVE SCREEN without a SET SCREEN before it, the current screen process will be terminated and branch directly to the screen specified as the default next-screen in the screen attributes.
38. What is the meaning of the screen number ‘0’?
In “calling mode”, the special screen number 0 (LEAVE TO SCREEN 0) root the system to jump back to the preceding call level. That is, if you have called a screen sequence with CALL SCREEN leaving to screen 0 ends the sequence and returns to the calling screen. If you have not called a screen sequence, LEAVE TO SCREEN 0 ends the transaction.
39. What does the ‘SUPPRESS DIALOG’ do?
Suppressing of whole screens is feasible with this command. This command permits us to carry out screen processing “in the background”. Suppressing screens is helpful when we are branching to list-mode from a transaction dialog step.
40. What is the significance of the memory table ‘SCREEN’?
At runtime, characteristic for each screen field are stored in the memory table called ‘SCREEN’. We need not speak out this table in our program. The system keeps the table for us internally and updates it with every screen change.
- Yes
30. The field SY-DYNR refers to--------------
Number of the current screen.
31. What is dialog Module?
- A dialog Module is a callable sequence of screens that does not belong to a particular transaction. Dialog modules have their module pools, and can be called by any transaction.
32. The Syntax used to call a screen as dialog box (pop up)is---------
CALL SCREEN
STARTING AT
ENDING AT
33. What is “call mode”?
- In the ABAP/4 WORLD each stackable series of screens is a “call mode”, This is IMP because of the way u return from the given sequence .To finish a call mode and return to a suspended chain set the “next screen” to 0 and leave to it:
LEAVE TO SCREEN 0 or (SET SCREEN 0 and LEAVE SCREEN) .When u return to the suspended chain execution resumes with the statement directly following the original CALL SCREEN statement.The original sequence of screens in a transaction (that is , without having stacked any additional call modes),you returned from the transaction altogether.
34. The max number of calling modes stacked at one time is?
- NINE
35. What is LUW or Data base Transaction?
- A “LUW”(logical unit of work) is the span of time during which any database updates must be carry out in an “all or nothing” manner .Moreover they are all performed (committed),or they are all thrown away (rolled back).In the ABAP/4 world , LUWs and
- Transactions can have several meanings:
LUW (or “database LUW” or “database transaction”)
This is the set of updates finished by a database commit. A LUW lasts, at most, from one screen change to the next (because the SAP system triggers database commits automatically at every screen change).
36. What is SAP LUW or Update Transaction?
Update transaction (or “SAP LUW”)
This is a set of updates terminated by an ABAP/4 commit. A SAP LUW may last much longer than a database LUW, since most update processing extends over multiple transaction screens. The programmer terminates an update transaction by issuing a COMMIT WORK statement.
37. What occur if only one of the commands SET SCREEN and LEAVE SCREEN is used with no using the other?
If we use SET SCREEN without LEAVE SCREEN, the program finishes processing for the present screen before branching to. If we use LEAVE SCREEN without a SET SCREEN before it, the current screen process will be terminated and branch directly to the screen specified as the default next-screen in the screen attributes.
38. What is the meaning of the screen number ‘0’?
In “calling mode”, the special screen number 0 (LEAVE TO SCREEN 0) root the system to jump back to the preceding call level. That is, if you have called a screen sequence with CALL SCREEN leaving to screen 0 ends the sequence and returns to the calling screen. If you have not called a screen sequence, LEAVE TO SCREEN 0 ends the transaction.
39. What does the ‘SUPPRESS DIALOG’ do?
Suppressing of whole screens is feasible with this command. This command permits us to carry out screen processing “in the background”. Suppressing screens is helpful when we are branching to list-mode from a transaction dialog step.
40. What is the significance of the memory table ‘SCREEN’?
At runtime, characteristic for each screen field are stored in the memory table called ‘SCREEN’. We need not speak out this table in our program. The system keeps the table for us internally and updates it with every screen change.
SAP Transactions
1. What is a transaction?
- A transaction is dialog program that modify data objects in a consistent way.
2. What are the necessities of a dialog program must complete?
A dialog program should fulfill the following requirements
- a user friendly user interface.
- Format and consistency checks for the data entered by the user.
- Easy alteration of input errors.
- Access to data by storing it in the data bases.
3. What are the fundamental components of dialog program?
- Screens (Dynpros)
- Each dialog in an SAP system is controlled by dynpros. A dynpros consists of a screen
And its flow logic and controls just one dialog step.
- ABAP/4 module Pool.
Each dynpro refers to exactly one ABAP/4 dialog program .Such a dialog program is also referred as module pool, since it consists of interactive modules.
4. What is PBO and PAI events?
PBO- Process Before Output-It find out the flow logic before displaying the screen.
PAI-Process After Input-It find out the flow logic after the display of the screen and after receiving inputs from the User.
5. What is dynpro? What are its components?
- A dynpro (Dynamic Program) consists of a screen and its flow logic and controls exactly one dialog steps.
- The different components of the dynpro are :
Flow Logic: calls of the ABAP/4 modules for a screen .
Screen layout: Positions of the text, fields, pushbuttons and so on for a screen
Screen feature: Number of the screen, number of the subsequent screen and others
Fields aspects: Definition of the attributes of the individual fields on a screen.
6. What is a ABAP/4 module pool?
-Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also refer as
a module pool ,since it consists on interactive modules.
7..Can we use WRITE statements in screen fields if no then how is data relocate from field data to screen fields?
-We cannot write field data to the screen using the WRITE statement. The system instead shift data by evaluating screen fields names with ABAP/4 variable names. If both names are the same, it
transfers screen fields values to ABAP/4 programs fields and Vice Versa. This happens instantly after displaying the screen.
8. Can we make use of flow logic control key words in ABAP/4 and vice-versa?
- The flow control of a dynpro consists of a few statements that syntactically reassemble ABAP/4 statements .However ,We cannot use flow control keywords in ABAP/4 and vice-versa.
9. What is GUI standing? How to create /Edit GUI status?
-A GUI status is a subset of the interface elements used for a definite screen. The status comprises those elements that are at present needed by the transaction .The GUI status for a transaction may be composed of the following elements:
-Title bar.
-Mneu bar.
-Application tool bar
-Push buttons.
To generate and edit GUI status and GUI title, we use the Menu Painter.
10. How does the interface between the Dynpro and the ABAP/4 Modules takes place?
-A transaction is a set of screens and ABAP/4 routines, controlled and carry out by a Dialog processor. The Dilaog processor processes screen after the screen, thus triggering the proper ABAP/4 processing of each screen .For each screen, the system process the flow logic that contains the equivalent ABAP/4 processing. The controls passes from screen flow logic to ABAP/4 code and back.
11. How does the Dialog handle user requests?
- when an act is carried out ,the system triggers the PROCESS AFTER INPUT event. The data passed includes field screen data filled by the user and a function code. A function code is a technical name that has been allocated in a screen Painter or Menu Painter to a menu entry, a push button, the ENTER key or a function Key of a screen. An internal work field(ok-code)in the PAI module weigh up the function code, and the suitable action is taken.
12. What is to be defined for a push button fields in the screen attributes?
- A function code has to be defined in the screen attributes for the push buttons in a screen.
13. How the function code is handles in Flow Logic?
- When the User selects a function in a transaction, the system duplicate the function code into a specifically designated work field called OK_CODE. This field is Global in ABAP/4 Module Pool. The OK_CODE can then be calculated in the corresponding PAI module. The function code is always passed in exactly the same way, regardless of whether it comes from a screen’s pushbutton, a menu
option, function key or other GUI element.
14. What controls the screen flow?
- The SET SCREEN and LEAVE SCREEN statements controls screen flow.
15. The Function code at presently active is determined by what Variable?
- The function code presently active in a Program can be determined from the SY-UCOMM Variable.
16. What are the “field” and “chain” Statements?
- The FIELD and CHAIN flow logic declaration let you Program Your own checks. FIELD and CHAIN tell the system which fields you are checking and Whether the System should carry out Checks in the flow logic or call an ABAP/4 Module.
17. What is an “on input filed” statements?
- ON INPUT
The ABAP/4 module is called only if a field have the Value other than the initial Value. This first Value is determined by the field’s Data Type: blanks for character Fields, Zeroes for numeric. If the user modify the Fields Value back t o its initial value, ON INPUT does not trigger a call.
18. What is an “on request Field” statement?
- ON REQUEST
The ABAP/4 Module is called only if the client has entered the value in the field value since the last screen display .The Value counts as changed Even if the User simply types in the value that was previously there .In common ,the ON REQUEST condition is triggered through any
Form of” MANUAL INPUT’.
19. What is an on”*-input filed” statement?
ON *-INPUT
- The ABAP/4 module is called if the user has entered the “*” in the first character of the field, and the field has the feature *-entry in the screen Painter.You can use this option in Exceptionla cases where you want to check only fields with certain Kinds of Input.
20. What is conditional chain statement?
ON CHAIN-INPUT similar to ON INPUT.
The ABAP/4 module is called if any one of the fields in the chain contains a value other than its initial value (blank or nulls).
ON CHAIN-REQUEST
This state functions just like ON REQUEST, but the ABAP/4 module is called if any one of the fields in the chain changes value.
21. What is “at exit-command:?
The flowlogic Keyword at EXIT-COMMAND is a particular addition to the MODULE statement in the Flow Logic .AT EXIT-COMMAND lets you call a module ahead of the system executes the automatic fields checks.
22. Which Function type has to be used for using “at exit-command” ?
- To Use AT EXIT – COMMAND, We must allocate a function Type “E” to the applicable function in the MENU Painter OR Screen Painter.
23. What are the different message types available in the ABAP/4 ?
- There are 5 types of message types available.
- E: ERROR
- W-WARNING
- I –INFORMATION
- A-ABNORMAL TERMINATION.
- S-SUCCESS
Of the two “ next screen “ attributes the attributes that has more priority is -------------------.
Dynamic.
Navigation to a subsequent screen can be specified statically/dynamically .(TRUE/FALSE).
TRUE.
Dynamic screen chain for a screen can be set using ------------- and ----------------- commands
Set Screen, Call screen.
27. The commands through Which an ABAP/4 Module can “branch to “ or “call” the next screen are
1.------------,2--------------,3---------------,4------------.
- Set screen,Call screen ,Leave screen, Leave to screen .
28. What is difference between SET SCREEN and CALL SCREEN ?
- With SET SCREEN the present screen only spell out the next screen in the chain , control branches to this next screen as soon as the present screen has been processed .Return from next screen to present screen is not automatic .It does not interrupt processing of the current screen. If we want to branch to the next screen without finishing the current one ,use LEAVE SCREEN.
- With CALL SCREEN , the existing (calling) chain is suspended , and a next screen (screen chain) is called .The called can then return to the suspended chain with the statement LEAVE SCREEN TO SCREEN 0 .Sometime we might want to let an user call a pop up screen from the main application screen to let him enter secondary information. After they have completed their entries, the users should be able to close the popup and return directly to the place where they left off in the main screen. Here comes CALL SCREEN into picture .This statement lets us insert such a sequence into the current one.
- A transaction is dialog program that modify data objects in a consistent way.
2. What are the necessities of a dialog program must complete?
A dialog program should fulfill the following requirements
- a user friendly user interface.
- Format and consistency checks for the data entered by the user.
- Easy alteration of input errors.
- Access to data by storing it in the data bases.
3. What are the fundamental components of dialog program?
- Screens (Dynpros)
- Each dialog in an SAP system is controlled by dynpros. A dynpros consists of a screen
And its flow logic and controls just one dialog step.
- ABAP/4 module Pool.
Each dynpro refers to exactly one ABAP/4 dialog program .Such a dialog program is also referred as module pool, since it consists of interactive modules.
4. What is PBO and PAI events?
PBO- Process Before Output-It find out the flow logic before displaying the screen.
PAI-Process After Input-It find out the flow logic after the display of the screen and after receiving inputs from the User.
5. What is dynpro? What are its components?
- A dynpro (Dynamic Program) consists of a screen and its flow logic and controls exactly one dialog steps.
- The different components of the dynpro are :
Flow Logic: calls of the ABAP/4 modules for a screen .
Screen layout: Positions of the text, fields, pushbuttons and so on for a screen
Screen feature: Number of the screen, number of the subsequent screen and others
Fields aspects: Definition of the attributes of the individual fields on a screen.
6. What is a ABAP/4 module pool?
-Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also refer as
a module pool ,since it consists on interactive modules.
7..Can we use WRITE statements in screen fields if no then how is data relocate from field data to screen fields?
-We cannot write field data to the screen using the WRITE statement. The system instead shift data by evaluating screen fields names with ABAP/4 variable names. If both names are the same, it
transfers screen fields values to ABAP/4 programs fields and Vice Versa. This happens instantly after displaying the screen.
8. Can we make use of flow logic control key words in ABAP/4 and vice-versa?
- The flow control of a dynpro consists of a few statements that syntactically reassemble ABAP/4 statements .However ,We cannot use flow control keywords in ABAP/4 and vice-versa.
9. What is GUI standing? How to create /Edit GUI status?
-A GUI status is a subset of the interface elements used for a definite screen. The status comprises those elements that are at present needed by the transaction .The GUI status for a transaction may be composed of the following elements:
-Title bar.
-Mneu bar.
-Application tool bar
-Push buttons.
To generate and edit GUI status and GUI title, we use the Menu Painter.
10. How does the interface between the Dynpro and the ABAP/4 Modules takes place?
-A transaction is a set of screens and ABAP/4 routines, controlled and carry out by a Dialog processor. The Dilaog processor processes screen after the screen, thus triggering the proper ABAP/4 processing of each screen .For each screen, the system process the flow logic that contains the equivalent ABAP/4 processing. The controls passes from screen flow logic to ABAP/4 code and back.
11. How does the Dialog handle user requests?
- when an act is carried out ,the system triggers the PROCESS AFTER INPUT event. The data passed includes field screen data filled by the user and a function code. A function code is a technical name that has been allocated in a screen Painter or Menu Painter to a menu entry, a push button, the ENTER key or a function Key of a screen. An internal work field(ok-code)in the PAI module weigh up the function code, and the suitable action is taken.
12. What is to be defined for a push button fields in the screen attributes?
- A function code has to be defined in the screen attributes for the push buttons in a screen.
13. How the function code is handles in Flow Logic?
- When the User selects a function in a transaction, the system duplicate the function code into a specifically designated work field called OK_CODE. This field is Global in ABAP/4 Module Pool. The OK_CODE can then be calculated in the corresponding PAI module. The function code is always passed in exactly the same way, regardless of whether it comes from a screen’s pushbutton, a menu
option, function key or other GUI element.
14. What controls the screen flow?
- The SET SCREEN and LEAVE SCREEN statements controls screen flow.
15. The Function code at presently active is determined by what Variable?
- The function code presently active in a Program can be determined from the SY-UCOMM Variable.
16. What are the “field” and “chain” Statements?
- The FIELD and CHAIN flow logic declaration let you Program Your own checks. FIELD and CHAIN tell the system which fields you are checking and Whether the System should carry out Checks in the flow logic or call an ABAP/4 Module.
17. What is an “on input filed” statements?
- ON INPUT
The ABAP/4 module is called only if a field have the Value other than the initial Value. This first Value is determined by the field’s Data Type: blanks for character Fields, Zeroes for numeric. If the user modify the Fields Value back t o its initial value, ON INPUT does not trigger a call.
18. What is an “on request Field” statement?
- ON REQUEST
The ABAP/4 Module is called only if the client has entered the value in the field value since the last screen display .The Value counts as changed Even if the User simply types in the value that was previously there .In common ,the ON REQUEST condition is triggered through any
Form of” MANUAL INPUT’.
19. What is an on”*-input filed” statement?
ON *-INPUT
- The ABAP/4 module is called if the user has entered the “*” in the first character of the field, and the field has the feature *-entry in the screen Painter.You can use this option in Exceptionla cases where you want to check only fields with certain Kinds of Input.
20. What is conditional chain statement?
ON CHAIN-INPUT similar to ON INPUT.
The ABAP/4 module is called if any one of the fields in the chain contains a value other than its initial value (blank or nulls).
ON CHAIN-REQUEST
This state functions just like ON REQUEST, but the ABAP/4 module is called if any one of the fields in the chain changes value.
21. What is “at exit-command:?
The flowlogic Keyword at EXIT-COMMAND is a particular addition to the MODULE statement in the Flow Logic .AT EXIT-COMMAND lets you call a module ahead of the system executes the automatic fields checks.
22. Which Function type has to be used for using “at exit-command” ?
- To Use AT EXIT – COMMAND, We must allocate a function Type “E” to the applicable function in the MENU Painter OR Screen Painter.
23. What are the different message types available in the ABAP/4 ?
- There are 5 types of message types available.
- E: ERROR
- W-WARNING
- I –INFORMATION
- A-ABNORMAL TERMINATION.
- S-SUCCESS
Of the two “ next screen “ attributes the attributes that has more priority is -------------------.
Dynamic.
Navigation to a subsequent screen can be specified statically/dynamically .(TRUE/FALSE).
TRUE.
Dynamic screen chain for a screen can be set using ------------- and ----------------- commands
Set Screen, Call screen.
27. The commands through Which an ABAP/4 Module can “branch to “ or “call” the next screen are
1.------------,2--------------,3---------------,4------------.
- Set screen,Call screen ,Leave screen, Leave to screen .
28. What is difference between SET SCREEN and CALL SCREEN ?
- With SET SCREEN the present screen only spell out the next screen in the chain , control branches to this next screen as soon as the present screen has been processed .Return from next screen to present screen is not automatic .It does not interrupt processing of the current screen. If we want to branch to the next screen without finishing the current one ,use LEAVE SCREEN.
- With CALL SCREEN , the existing (calling) chain is suspended , and a next screen (screen chain) is called .The called can then return to the suspended chain with the statement LEAVE SCREEN TO SCREEN 0 .Sometime we might want to let an user call a pop up screen from the main application screen to let him enter secondary information. After they have completed their entries, the users should be able to close the popup and return directly to the place where they left off in the main screen. Here comes CALL SCREEN into picture .This statement lets us insert such a sequence into the current one.
PHP Interview Questions - 4
1What is PHP?
PHP Version 3.0 is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.
2 What is its relation to PHP/FI?
PHP is the successor to PHP/FI 2.0.
3 Can I run both PHP/FI 2.0 and PHP at the same time?
Yes, PHP was written so as to not interfere with an existing PHP/FI 2 installation. Instructions for building Apache 1.3.0 with both PHP/FI 2 and PHP modules can be found HERE. A different spin on this is HERE, although the first step where the PHP2 regex code is substituted with the PHP regex code seems redundant. The two regex dirs are pretty much identical.
4 What are the differences between PHP and PHP/FI 2.0?
For a complete list of the changes, read the CHANGES file included in the PHP distribution. Some highlights:
· All-new parser.
· Persistent database connections.
· A native Windows95/NT port.
· IMAP, SNMP, and LDAP extensions.
5 I heard it's possible to access Microsoft SQL Server from PHP. How?
On Windows 95/NT machines, you can simply use the included ODBC support and the correct ODBC driver.
On Unix machines, you can use the Sybase-CT driver to access Microsoft SQL Servers because they are (at least mostly) protocol-compatible. Sybase has made a free version of the necessary libraries for Linux systems. For other Unix operating systems, you need to contact Sybase for the correct libraries. Also see the answer to the next question - 1.6.
6 Can I access Microsoft Access databases?
Yes. You already have all the tools you need if you are running entirely under Windows 95/98 or NT, where you can use ODBC and Microsoft's ODBC drivers for Microsoft Access databases.
If you are running PHP on a Unix box and want to talk to MS-Access on a Windows box you will need Unix ODBC drivers. OpenLink Software has Unix-based ODBC drivers that can do this. There is a free pilot program where you can download an evaluation copy that doesn't expire and prices start at $675 for the commercial supported version.
Another alternative is to use an SQL server that has Windows ODBC drivers and use that to store the data, which you can then access from Microsoft Access (using ODBC) and PHP (using the built-in drivers), or to use an intermediary file format that Access and PHP both understand, such as flat-files or dBase databases. On this point Tim Hayes from OpenLink software writes:
Using another database as an intermediary is not a good idea, when you can use ODBC from PHP straight to your database - i.e. with OpenLink's drivers. If you do need to use an intermediary file format, OpenLink have now released Virtuoso (a virtual database engine) for NT, Linux and other unix platforms. Please visit our website for a free download.
One option that has proven successful is to use MySQL and its MyODBC drivers on Windows and synchronizing the databases. Steve Lawrence writes:
1. Install MySQL on your platform according to instructions with MySQL. Latest available from www.mysql.org (get it from your mirror!). No special configuration required except when you set up a database, and configure the user account, you should put % in the host field, or the host name of the Windows computer you wish to access MySQL with. Make a note of your server name, username, and password.
2. Download the MyODBC for Windows driver from the MySQL site. Latest release is myodbc-2_50_19-win95.zip (NT available too, as well as source code). Install it on your Windows machine. You can test the operation with the utilities included with this program.
3. Create a user or system dsn in your ODBC administrator, located in the control panel. Make up a dsn name, enter your hostname, user name, password, port, etc for you MySQL database configured in step 1.
4. Install Access with a full install, this makes sure you get the proper add-ins.. at the least you will need ODBC support and the linked table manager.
5. Now the fun part! Create a new access database. In the table window right click and select Link Tables, or under the file menu option, select Get External Data and then Link Tables. When the file browser box comes up, select files of type: ODBC. Select System dsn and the name of your dsn created in step 3. Select the table to link, press ok, and presto! you can now open the table and add/delete/edit data on your MySQL server! You can also build queries, import/export tables to MySQL, build forms and reports, etc.
Tips and Tricks: - You can construct your tables in access and export them to MySQL, then link them back in. That makes table creation quick.
- When creating tables in access, you must have a primary key defined in order to have write access to the table in access. Make sure you create a primary key in MySQL before linking in access.
- If you change a table in MySQL, you have to re-link it in access. Go to tools>add-ins>linked table manager, cruise to your ODBC DSN, and select the table to re-link from there. you can also move your dsn source around there, just hit the always prompt for new location checkbox before pressing ok.
7 Is there a PHP mailing list?
Of course! To subscribe, send mail to php3-subscribe@lists.php.net. You don't need to include anything special in the subject or body of the message.
To unsubscribe, send mail to php3-unsubscribe@lists.php.net.
8 Help! I can't seem to subscribe to the mailing list!
Help! I can't seem to unsubscribe from the mailing list!
If you have problems subscribing to or unsubscribing from the PHP mailng list, it may be because the mailing list software can't figure out the correct mailing address to use. If your email address was joeblow@example.com, you can send your subscription request to php3-subscribe-joeblow=example.com@lists.php.net, or your unsubscription request to php3-unsubscribe-joeblow=example.com@lists.php.net.
9 Is there an archive of the mailing list anywhere?
Yes, you will find a list of archive sites on the Support page.
10 How did you do those pop-out windows for the Search and Mirror buttons?
Our site designer, Colin Viebrock (cmv@privateworld.com), says:
Those fancy pop-out layers are done with Dynamic HTML (DHTML), Cascading Style Sheets (CSS) and Javascript (version 1.2).
There are plenty of references on the web about DHTML and CSS, including:
· CSS Level 1 Spec: www.w3.org/TR/REC-CSS1
· Macromedia's DHTML Zone: www.dhtmlzone.com/index.html
· Webreference's DHTML Lab: www.webreference.com/dhtml/
· Guide to Cascading Style Sheets: www.htmlhelp.com/reference/css/
· Dynamic Duo - Cross-Browser DHTML: www.dansteinman.com/dynduo/
· Netscape's Guide to JS 1.2: developer.netscape.com/docs/manuals/communicator/jsguide/js1_2.htm
But your best source of information is to view the source code to the pages on the PHP site. To see the actual DHTML/Javascript code, use your browser's "View Source" function. To see how this code was generated dynamically using PHP, click on the "Source" button in the upper-right corner of any PHP page. You will probably also want to view the source of the "shared.inc" file - there is a link to it at the bottom of every source page.
11 Can I access Empress RDBMS databases?
Yes. PHP 3.0.6 and Empress RDBMS v8.10 and higher are compatible.
You already have all the tools you need if you are running entirely under Windows 95/98 or NT, where you can use ODBC and the Empress ODBC driver for Windows.
If you are running PHP on a Unix box and want to access Empress databases, you can link the Empress ODBC client driver directly into the PHP unified ODBC API.
Note that does NOT make PHP an ODBC client. The unified ODBC interface simplies uses the ODBC application program interface (API).
Because Empress uses the PHP unified ODBC interface it has very little explicit Empress specific syntax. It is of course possible to use Empress specific SQL in the SQL statements themselves, but this does not affect the interface. It is a good general policy to stick to ANSI standard SQL whenever possible.
Empress Specifics: The only item which is specific to Empress in PHP is that there are two methods for specifying the DNS in the odbc_connect ()odbc_pconnect () functions. The connect syntax is: and
odbc_connect (dsn, user_id, password)
odbc_pconnect (dsn, user_id, password)
For Empress dsn can be specified as either:
Data source name
This is the logical database name specified in the ODBC.INI file.
A full connection string, as specified in the ODBC standard.
eg
dsn="DATABASE=db_name;SERVER=server_name;PORT=server_port"
Note that there are other options for this string. But the three shown above are the most important for use with PHP.
Which of these you use is up to you. There are advantages and disadvantages to both. Using the full connection string means that you do NOT require an ODBC.INI file to access the database. However, if you move the datasource, or change the port on which the RDBMS server listens, you will have to modify every call to the odbc_connect/pconnect function.
The choice is yours...
Empress Installation: In order to add the Empress interface to PHP you require an Empress RDBMS with the Empress Connectivity option. If your PHP installation is on the same platform as the RDBMS then setting EMPRESS_PATH to the installation directory will automatically locate the Empress ODBC client driver. However, if the PHP installation is on a separate platform from the RDBMS you will also require an ODBC client on that platform, and you will need to specify the location of the driver when configuring the PHP installation.
2. Obtaining PHP
1 Where can I obtain PHP?
You can download PHP from any of the members of the PHP network of sites. These can be found at http://www.php.net/. You can also use anonymous CVS to get the absolute latest version of the source. For more information, go to http://cvs.php.net.
2 Are pre-compiled binary versions available?
Yes, although they are not always up to date. The Windows binary is generally current, but the Unix binaries lag behind and are only available for certain platforms.
3 Where can I get libraries needed to compile some of the optional PHP extensions?
Note: Those marked with * are not thread-safe libraries, and should not be used with PHP as a server module in the multi-threaded Windows web servers (IIS, Netscape). This does not matter in Unix environments, yet.
· LDAP (unix): ftp://ftp.openldap.org/pub/openldap/openldap-stable.tgz
· LDAP* (unix): ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z
· LDAP (unix/win): Netscape Directory (LDAP) SDK 1.1 There is also a free LDAP server at: ftp://ftp.critical-angle.com/pub/cai/slapd/.
· Berkeley DB2 (Unix/Win): http://www.sleepycat.com/
· SNMP* (Unix): http://www.ece.ucdavis.edu/ucd-snmp/ (Note: PHP uses the native SNMP interface in Windows.)
· GD* (Unix/Win): http://www.boutell.com/gd/#buildgd
· mSQL* (Unix): http://www.hughes.com.au/
· mSQL* (Win) : MSQL PC Home Page
· MySQL (Unix): http://www.mysql.com/
· IMAP* (Win/Unix): ftp://ftp.cac.washington.edu/imap/old/imap-4.5.tar.Z
· Sybase-CT* (Linux, libc5): Available locally
· FreeType (libttf): http://www.freetype.org/
· ZLib (Unix/Win32): http://www.cdrom.com/pub/infozip/zlib/
· expat XML parser (Unix/Win32): http://www.jclark.com/xml/expat.html
· PDFLib: http://www.pdflib.com
· mcrypt: ftp://argeas.cs-net.gr/pub/unix/mcrypt/
· mhash: http://sasweb.de/mhash/
· t1lib: http://www.neuroinformatik.ruhr-uni-bochum.de/ini/PEOPLE/rmz/t1lib/t1lib.html
· dmalloc: http://www.dmalloc.com/
· aspell: http://metalab.unc.edu/kevina/aspell/aspell-.26.2.tar.gz
· Readline: ftp://prep.ai.mit.edu/pub/gnu/readline/
4 How do I get these libraries to work?
You will need to follow instructions provided with the library. Some of these libraries are detected automatically when you run the 'configure' script of PHP (such as the GD library), and others you will have to enable using '--with-EXTENSION' options to 'configure'. Run 'configure --help' for a listing of these.
5 I got the latest version of the PHP source code from the CVS repository on my Windows 95/NT machine, what do I need to compile it?
First, you will need Microsoft Visual C++ v6 (v5 may do it also, but we do it with v6), and you will need to download the support files. You will need to unzip this file (which has subdirectories, so make sure your unzip program keeps them) into the win32 subdirectory of the source distribution.
6 Where do I find the Browser Capabilities File?
You can find PHP's own browscap.ini file at http://php.netvision.net.il/browscap/. There is also another browscap.ini file at http://www.cyscape.com/asp/browscap/.
3. Installation
To install PHP, follow the instructions in the INSTALL file located in the distribution. Windows 95 and NT users should also read the README.WIN32 file.
If you are trying to install PHP for use with Netscape's web server on Unix see: http://www.webgenx.com/php/phpnes.php3
1 Where should my php3.ini file be located?
By default on UNIX it should be in /usr/local/lib. Most people will want to change this at compile-time with the --with-config-file-path flag. You would, for example, set it to something like:
--with-config-file-path=/etc
And then you would copy php3.ini-dist from the distribution to /etc/php3.ini and edit it to make any local changes you want.
2 I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here?
· Assuming you installed Apache PHP completely with RPMS, you need to uncomment or add some or all of the following lines in your http.conf file:
# Extra Modules
AddModule mod_php.c
AddModule mod_php3.c
AddModule mod_perl.c
# Extra Modules
LoadModule php_module modules/mod_php.so
LoadModule php3_module modules/libphp3.so
LoadModule perl_module modules/libperl.so
· And add:
AddType application/x-httpd-php3 .php3
To the global properties, or to the properties of the VirtualDomain you want to have PHP support added to.
3 I installed PHP using RPMS, but it doesn't compile with the database support I need! What's going on here?
Due to the way PHP is currently built, it is not easy to build a complete flexible PHP RPM. This issue will be addressed in PHP4. For PHP, we currently suggest you use the mechanism described in the INSTALL.REDHAT file in the PHP distribution. If you insist on using an RPM version of PHP, read on...
Currently the RPM packagers are setting up the RPMS to install without database support to simplify installations AND because RPMS use /usr/ instead of the standard /usr/local/ directory for files. You need to tell the RPM spec file which databases to support and the location of the top-level
This example will explain the process of adding support for the popular MySQL database server, using the mod installation for Apache.
Of course all of this information can be adjusted for any database server that PHP supports. I will assume you installed MySQL and Apache completely with RPMS for this example as well. of your database server.
· First remove mod_php3
rpm -e mod_php3
· Then get the source rpm and INSTALL it, NOT --rebuild
rpm -Uvh mod_php3-3.0.5-2.src.rpm
· Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
In the %build section add the database support you want, and the path.
For MySQL you would add --with-mysql=/usr \
The %build section will look something like this:
./configure --prefix=/usr \
--with-apxs=/usr/sbin/apxs \
--with-config-file-path=/usr/lib \
--enable-debug=no \
--enable-safe-mode \
--with-exec-dir=/usr/bin \
--with-mysql=/usr \
--with-system-regex
· Once this modification is made then build the binary rpm as follows:
rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
· Then install the rpm
rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
Make sure you restart Apache, and you now have PHP with MySQL support using RPM's. Note that it is probably much easier to just build from the distribution tarball of PHP and follow the instructions in INSTALL.REDHAT found in that distribution.
4. Build Problems
1 I got the latest version of PHP using the anonymous CVS service, but there's no configure script!
You have to have the GNU autoconf package installed so you can generate the configure script from configure.in. Just run make -f build.mk in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the --enable-maintainer-mode option, the configure script will not automatically get rebuilt when the configure.in file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or config.status is run.)
2 I'm having problems configuring PHP to work with Apache. It says it can't find httpd.h, but it's right where I said it is!
You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify '--with-apache=/path/to/apache' and not '--with-apache=/path/to/apache/src'.
3 When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package!
You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as:
CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
If you're using a csh-variant for your login shell (why?), it would be:
env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
4 When it is compiling the file language-parser.tab.c, it gives me errors that say 'yytname undeclared'.
You need to update your version of Bison. You can find the latest version at ftp://prep.ai.mit.edu/pub/gnu/.
5 When I run 'make', it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files.
Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running "cp *.o functions" and then re-running 'make' to see if that helps. If it does, you should really upgrade to a recent version of GNU make.
6 When linking PHP, it complains about a number of undefined references.
Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included.
If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the INSTALL file that comes with the distribution for more information.
Some people have also reported that they had to add '-ldl' immediately following 'libphp3.a' when linking with Apache.
7 I can't figure out how to build PHP with Apache 1.3.
This is actually quite easy. Follow these steps carefully:
· Grab the latest Apache 1.3 distribution from www.apache.org.
· Ungzip and untar it somewhere, for example /usr/local/src/apache-1.3.
· Compile PHP by first running ./configure --with-apache=//apache-1.3 (substitute for the actual path to your apache-1.3 directory.
· Type 'make' followed by 'make install' to build PHP and copy the necessary files to the Apache distribution tree.
· Change directories into to your //apache-1.3/src directory and edit the Configuration file. At the end of the file, add: AddModule modules/php3/libphp3.a.
· Type: './Configure' followed by 'make'.
· You should now have a PHP-enabled httpd binary!
Note: You can also use the new Apache ./configure script. See the instructions in the README.configure file which is part of your Apache distribution. Also have a look at the INSTALL file in the PHP distribution.
8 I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file. Help!
This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help:
· Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: /path/to/binary/httpd -l
If you don't see mod_php3.c listed then you are not running the right binary. Find and install the correct binary.
· Make sure you have added the correct Mime Type to one of your Apache .conf files. It should be: AddType application/x-httpd-php3 .php3
Also make sure that this AddType line is not hidden away inside a or block which would prevent it from applying to the location of your test script.
· Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly.
9 It says to use: --activate-module=src/modules/php3/libphp3.a, but that file doesn't exist, so I changed it to --activate-module=src/modules/php3/libmodphp3.a and it doesn't work!? What's going on?
Well, you decided to try to outsmart the people who wrote those nice step-by-step instructions for you and you have now discovered that these people cannot be outsmarted. The libphp3.a file is not supposed to exist. The Apache build process will create it.
10 When I try to build Apache with PHP as a static module using --activate-module=src/modules/php3/libphp3.a it tells me that my compiler is not ANSI compliant.
This is a crappy error message and has been fixed in Apache-1.3.10 (not available yet). For now, go and edit the src/Configure file in the Apache source directory and down around line 2140 you will find a line that looks like this:
if ./helpers/TestCompile sanity; then
Change this line to be this:
if ./helpers/TestCompile -v sanity; then
and now re-run the Apache configure script. It will now show you the actual errors that caused your build to fail. It is usually due to a missing library.
11 When I try to build PHP using --with-apxs I get strange error messages
There are two things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Edit your apxs (sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs) and check for these lines:
my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
If this is what you see, you have found your problem. Change these lines to say:
my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl
my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = q(-shared);# substituted via Makefile.tmpl
The second possible problem should only be an issue on RedHat-6.1. The apxs script RedHat ships is broken. Look for this line:
my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install
If you see the above line, change it to this:
my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install
5. Using PHP
1 I would like to write a generic PHP script that can handle data coming from any form. How do I know which POST method variables are available?
Make sure that the track_vars feature is enabled in your php3.ini file. If you compiled PHP with "--enable-track-vars" it will be on by default. Alternatively you can enable it at run-time on a per-script basis by putting at the top of your file. When track_vars is on, it creates three associative arrays. $HTTP_GET_VARS, $HTTP_POST_VARS and $HTTP_COOKIE_VARS. So, to write a generic script to handle POST method variables you would need something similar to the following:
while (list($var, $value) = each($HTTP_POST_VARS)) {
echo "$var = $value
\n";
}
2 I need to convert all single-quotes (') to a backslash followed by a single-quote. How can I do this with a regular expression?
First off, take a look at the addslashes() function. It will do exactly what you want. You should also have a look at the magic_quotes_gpc directive in your php3.ini file.
The ereg_replace magic you're looking for, however, is simply:
$escaped = ereg_replace("'", "\\'", $input);
3 When I do the following, the output is printed in the wrong order:
function myfunc($argument) {
echo $argument + 10;
}
$variable = 10;
echo "myfunc($variable) = " . myfunc($variable);
What's going on?
To be able to use the results of your function in an expression (such as concatenating it with other strings in the example above), you need to return the value, not echo it.
4 Hey, what happened to my newlines in:
1
2
In PHP, the ending for a block of code is either "?>" or "?>\n" (where \n means a newline). This means that you need to insert an extra newline after each block of PHP code in the above example.
Why does PHP do this? Because when formatting normal HTML, this usually makes your life easier because you don't want that newline, but you'd have to create extremely long lines or otherwise make the raw page source unreadable to achieve that effect.
5 I need to access information in the request header directly. How can I do this?
The getallheaders() function will do this if you are running PHP as a module. So, the following bit of code will show you all the request headers:
$headers = getallheaders();
for(reset($headers); $key = key($headers); next($headers)) {
echo "headers[$key] = ".$headers[$key]."
\n";
}
6 When I try to use authentication with IIS I get 'No Input file specified'
The security model of IIS is at fault here. This is a problem common to all CGI programs running under IIS. A workaround is to create a plain HTML file (not parsed by php) as the entry page into an authenticated directory. Then use a META tag to redirect to the PHP page, or have a link to the PHP page. PHP will then recognize the authentication correctly. When the ISAPI module is ready, this will no longer be a problem. This should not effect other NT web servers. For more information, see: http://support.microsoft.com/support/kb/articles/q160/4/22.asp.
7 I've followed all the instructions, but still can't get PHP and IIS to work together!
Make sure any user who needs to run a PHP script has the rights to run php.exe! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to php.exe. Also, any authenticated user will also need rights to execute php.exe. And for IIS4 you need to tell it that PHP is a script engine.
8 My PHP script works on IE and Lynx, but on Netscape some of my output is missing. When I do a "View Source" I see the content in IE but not in Netscape. Even when I telnet to port 80 directly the correct content shows up. How can this be? PHP is server-side and my browser can't possibly know that the content it is seeing is generated by PHP, so what is going on?
Very good question! ;) This is a tricky little issue and it has come up twice in the past month as of this writing. Both times I ended up spending a good 20 minutes trying to figure out what the heck was going on. The answer is that both IE and Lynx ignore any NULs (\0) in the HTML stream. Netscape does not. The best way to check for this is to compile the command-line version of PHP (also known as the CGI version) and run your script from the command line and pipe it through 'od -c' and look for any \0 characters. (If you are on Windows you need to find an editor or some other program that lets you look at binary files) When Netscape sees a NUL in a file it will typically not output anything else on that line whereas both IE and Lynx will. If this issue has bitten you, congratulations! You are not alone.
9 How do I get all the results from a SELECT MULTIPLE HTML tag?
The SELECT MULTIPLE tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. ie.
tag, but the $foo.x and $foo.y variables aren't available. Where are they?
When submitting a form, it is possible to use an image instead of the standard submit button with a tag like:
When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables: foo.x and foo.y.
Because $foo.x and $foo.y are invalid variable names in PHP, they are automagically converted to $foo_x and $foo_y. That is, the periods are replaced with underscores.
6. New Features
1 I saw PHP offers persistent database connections. What does that mean?
Persistent connections are SQL links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable).
People who aren't thoroughly familiar with the way web servers work and distribute the load may mistake persistent connects for what they're not. In particular, they do not give you an ability to open 'user sessions' on the same SQL link, they do not give you an ability to build up a transaction efficently, and they don't do a whole lot of other things. In fact, to be extremely clear about the subject, persistent connections don't give you any functionality that wasn't possible with their non-persistent brothers.
Why?
This has to do with the way web servers work. There are three ways in which your web server can utilize PHP to generate web pages.
The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP interpreter is created and destroyed for every page request (for a PHP page) to your web server. Because it is destroyed after every request, any resources that it acquires (such as a link to an SQL database server) are closed when it is destroyed. In this case, you do not gain anything from trying to use persistent connections -- they simply don't persist.
The second, and most popular, method is to run PHP as a module in a multiprocess web server, which currently only includes Apache. A multiprocess server typically has one process (the parent) which coordinates a set of processes (its children) who actually do the work of serving up web pages. When each request comes in from a a client, it is handed off to one of the children that is not already serving another client. This means that when the same client makes a second request to the server, it may be serviced by a different child process than the first time. What a persistent connection does for you in this case it make it so each child process only needs to connect to your SQL server the first time that it serves a page that makes us of such a connection. When another page then requires a connection to the SQL server, it can reuse the connection that child established earlier.
The last method is to use PHP as a plug-in for a multithreaded web server. Currently this is only theoretical -- PHP does not yet work as a plug-in for any multithreaded web servers. Work is progressing on support for ISAPI, WSAPI, and NSAPI (on Windows), which will all allow PHP to be used as a plug-in on multithreaded servers like Netscape FastTrack, Microsoft's Internet Information Server (IIS), and O'Reilly's WebSite Pro. When this happens, the behavior will be essentially the same as for the multiprocess model described before.
If persistent connections don't have any added functionality, what are they good for?
The answer here is extremely simple -- efficiency. Persistent connections are good if the overhead to create a link to your SQL server is high. Whether or not this overhead is really high depends on many factors. Like, what kind of database it is, whether or not it sits on the same computer on which your web server sits, how loaded the machine the SQL server sits on is and so forth. The bottom line is that if that connection overhead is high, persistent connections help you considerably. They cause the child process to simply connect only once for its entire lifespan, instead of every time it processes a page that requires connecting to the SQL server. This means that for every child that opened a persistent connection will have its own open persistent connection to the server. For example, if you had 20 different child processes that ran a script that made a persistent connection to your SQL server, you'd have 20 different connections to the SQL server, one from each child.
An important summary. Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should always be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It may (and probably will) change the efficiency of the script, but not its behavior!
7. Common Problems
1 I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here?
This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like:
· Stop your httpd processes
· gdb httpd
· > run -X -f /path/to/httpd.conf
· Then fetch the URL causing the problem with your browser
· If you are getting a core dump, gdb should inform you of this now
· type: bt
· Send the resulting backtrace to php-dev@lists.php.net
If your script uses the regular expression functions (ereg() and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. (This should happen automatically with PHP and Apache 1.3.x)
2 I'm trying to access one of the standard CGI variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function, and it can't seem to find it. What's wrong?
Environment variables are now normal global variables, so you must either declare them as global variables in your function (by using "global $DOCUMENT_ROOT;", for example) or by using the global variable array (ie, "$GLOBALS["DOCUMENT_ROOT"]".
3 I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions?
No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem.
4 I think I found a bug! Who should I tell?
You should go to the PHP Bug Database and make sure the bug isn't a known bug. If you don't see it in the database, use the reporting form to report the bug. It is important to use the bug database instead of just sending an email to one of the mailing lists because the bug will have a tracking number assigned and it will then be possible for you to go back later and check on the status of the bug. The bug database can be found at http://bugs.php.net.
8. Migrating from PHP2 to PHP3
1 When I add two strings together and then echo it, it echoes zero instead of the concatenation of the two strings! What's going on? Wouldn't it be great if adding two strings just concatenated them together?
PHP3 does not support the overloading of the addition operator for strings because values that arrive via the GET and POST methods and from databases are always stored as strings. This means that if the plus operator were overloaded to concatenate strings, you could add what you thought were two numbers and get the wrong result! (For example, "4" + "5" would be equal to "45".) One way around this would be to explicitly type-cast one or both of the operands, which is what PHP/FI 2 did.
This has been simplified in PHP3 by the addition of a real string concatenation operator. If you want to "add" two strings together, just write it like: "this" . "that" which will result in the string "thisthat".
The answer to the final part of the question is an emphatic no. Operator overloading can be a source of great confusion, especially when variables aren't very strongly typed to begin with, as they are in PHP3.
2 When I use the chmod(), umask(), or mkdir() functions, the permissions are wrong!
Unlike PHP/FI 2, PHP3 does not interpret the numeric arguments for these functions any differently than for any other function, which means you need to pass in an octal value if you are specifying an octal number, such as:
chmod($myfile, 0600);
not
chmod($myfile, 600);
3 I converted my script from PHP/FI 2.0 to PHP3 syntax, but now it just hangs! When I looked at the processes running on my server, there was one process that was chewing up all of the CPU cycles!
You probably missed the semi-colon on a while (condition); statement. This will cause PHP3 to spin out of control because it is simply executing an empty body for your while loop! Change the semi-colon to a colon and it should work correctly.
4 My user-functions don't work any more! I get a "Parse error (expecting '('" on the first line of the function.
PHP3's function declaration now resembles C function declarations, so your function should look like:
function printsum($a, $b) {
echo $a + $b;
}
You can also use old-style function declarations by use the 'old_function' designation, like so:
old_function printsum $a, $b (
echo $a + $b;
);
5 What happened to the securevar() function that was in PHP2? How can I make sure that a GET-method variable does not overwrite a POST-method one?
The securevar() function in PHP2 was a badly named function. It gave the impression that when used the POST-method was secure. It is not. It is only slightly more difficult to fake POST-method variables than GET-method ones.
$foo = $HTTP_POST_VARS["foo"];
PHP Version 3.0 is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.
2 What is its relation to PHP/FI?
PHP is the successor to PHP/FI 2.0.
3 Can I run both PHP/FI 2.0 and PHP at the same time?
Yes, PHP was written so as to not interfere with an existing PHP/FI 2 installation. Instructions for building Apache 1.3.0 with both PHP/FI 2 and PHP modules can be found HERE. A different spin on this is HERE, although the first step where the PHP2 regex code is substituted with the PHP regex code seems redundant. The two regex dirs are pretty much identical.
4 What are the differences between PHP and PHP/FI 2.0?
For a complete list of the changes, read the CHANGES file included in the PHP distribution. Some highlights:
· All-new parser.
· Persistent database connections.
· A native Windows95/NT port.
· IMAP, SNMP, and LDAP extensions.
5 I heard it's possible to access Microsoft SQL Server from PHP. How?
On Windows 95/NT machines, you can simply use the included ODBC support and the correct ODBC driver.
On Unix machines, you can use the Sybase-CT driver to access Microsoft SQL Servers because they are (at least mostly) protocol-compatible. Sybase has made a free version of the necessary libraries for Linux systems. For other Unix operating systems, you need to contact Sybase for the correct libraries. Also see the answer to the next question - 1.6.
6 Can I access Microsoft Access databases?
Yes. You already have all the tools you need if you are running entirely under Windows 95/98 or NT, where you can use ODBC and Microsoft's ODBC drivers for Microsoft Access databases.
If you are running PHP on a Unix box and want to talk to MS-Access on a Windows box you will need Unix ODBC drivers. OpenLink Software has Unix-based ODBC drivers that can do this. There is a free pilot program where you can download an evaluation copy that doesn't expire and prices start at $675 for the commercial supported version.
Another alternative is to use an SQL server that has Windows ODBC drivers and use that to store the data, which you can then access from Microsoft Access (using ODBC) and PHP (using the built-in drivers), or to use an intermediary file format that Access and PHP both understand, such as flat-files or dBase databases. On this point Tim Hayes from OpenLink software writes:
Using another database as an intermediary is not a good idea, when you can use ODBC from PHP straight to your database - i.e. with OpenLink's drivers. If you do need to use an intermediary file format, OpenLink have now released Virtuoso (a virtual database engine) for NT, Linux and other unix platforms. Please visit our website for a free download.
One option that has proven successful is to use MySQL and its MyODBC drivers on Windows and synchronizing the databases. Steve Lawrence writes:
1. Install MySQL on your platform according to instructions with MySQL. Latest available from www.mysql.org (get it from your mirror!). No special configuration required except when you set up a database, and configure the user account, you should put % in the host field, or the host name of the Windows computer you wish to access MySQL with. Make a note of your server name, username, and password.
2. Download the MyODBC for Windows driver from the MySQL site. Latest release is myodbc-2_50_19-win95.zip (NT available too, as well as source code). Install it on your Windows machine. You can test the operation with the utilities included with this program.
3. Create a user or system dsn in your ODBC administrator, located in the control panel. Make up a dsn name, enter your hostname, user name, password, port, etc for you MySQL database configured in step 1.
4. Install Access with a full install, this makes sure you get the proper add-ins.. at the least you will need ODBC support and the linked table manager.
5. Now the fun part! Create a new access database. In the table window right click and select Link Tables, or under the file menu option, select Get External Data and then Link Tables. When the file browser box comes up, select files of type: ODBC. Select System dsn and the name of your dsn created in step 3. Select the table to link, press ok, and presto! you can now open the table and add/delete/edit data on your MySQL server! You can also build queries, import/export tables to MySQL, build forms and reports, etc.
Tips and Tricks: - You can construct your tables in access and export them to MySQL, then link them back in. That makes table creation quick.
- When creating tables in access, you must have a primary key defined in order to have write access to the table in access. Make sure you create a primary key in MySQL before linking in access.
- If you change a table in MySQL, you have to re-link it in access. Go to tools>add-ins>linked table manager, cruise to your ODBC DSN, and select the table to re-link from there. you can also move your dsn source around there, just hit the always prompt for new location checkbox before pressing ok.
7 Is there a PHP mailing list?
Of course! To subscribe, send mail to php3-subscribe@lists.php.net. You don't need to include anything special in the subject or body of the message.
To unsubscribe, send mail to php3-unsubscribe@lists.php.net.
8 Help! I can't seem to subscribe to the mailing list!
Help! I can't seem to unsubscribe from the mailing list!
If you have problems subscribing to or unsubscribing from the PHP mailng list, it may be because the mailing list software can't figure out the correct mailing address to use. If your email address was joeblow@example.com, you can send your subscription request to php3-subscribe-joeblow=example.com@lists.php.net, or your unsubscription request to php3-unsubscribe-joeblow=example.com@lists.php.net.
9 Is there an archive of the mailing list anywhere?
Yes, you will find a list of archive sites on the Support page.
10 How did you do those pop-out windows for the Search and Mirror buttons?
Our site designer, Colin Viebrock (cmv@privateworld.com), says:
Those fancy pop-out layers are done with Dynamic HTML (DHTML), Cascading Style Sheets (CSS) and Javascript (version 1.2).
There are plenty of references on the web about DHTML and CSS, including:
· CSS Level 1 Spec: www.w3.org/TR/REC-CSS1
· Macromedia's DHTML Zone: www.dhtmlzone.com/index.html
· Webreference's DHTML Lab: www.webreference.com/dhtml/
· Guide to Cascading Style Sheets: www.htmlhelp.com/reference/css/
· Dynamic Duo - Cross-Browser DHTML: www.dansteinman.com/dynduo/
· Netscape's Guide to JS 1.2: developer.netscape.com/docs/manuals/communicator/jsguide/js1_2.htm
But your best source of information is to view the source code to the pages on the PHP site. To see the actual DHTML/Javascript code, use your browser's "View Source" function. To see how this code was generated dynamically using PHP, click on the "Source" button in the upper-right corner of any PHP page. You will probably also want to view the source of the "shared.inc" file - there is a link to it at the bottom of every source page.
11 Can I access Empress RDBMS databases?
Yes. PHP 3.0.6 and Empress RDBMS v8.10 and higher are compatible.
You already have all the tools you need if you are running entirely under Windows 95/98 or NT, where you can use ODBC and the Empress ODBC driver for Windows.
If you are running PHP on a Unix box and want to access Empress databases, you can link the Empress ODBC client driver directly into the PHP unified ODBC API.
Note that does NOT make PHP an ODBC client. The unified ODBC interface simplies uses the ODBC application program interface (API).
Because Empress uses the PHP unified ODBC interface it has very little explicit Empress specific syntax. It is of course possible to use Empress specific SQL in the SQL statements themselves, but this does not affect the interface. It is a good general policy to stick to ANSI standard SQL whenever possible.
Empress Specifics: The only item which is specific to Empress in PHP is that there are two methods for specifying the DNS in the odbc_connect ()odbc_pconnect () functions. The connect syntax is: and
odbc_connect (dsn, user_id, password)
odbc_pconnect (dsn, user_id, password)
For Empress dsn can be specified as either:
Data source name
This is the logical database name specified in the ODBC.INI file.
A full connection string, as specified in the ODBC standard.
eg
dsn="DATABASE=db_name;SERVER=server_name;PORT=server_port"
Note that there are other options for this string. But the three shown above are the most important for use with PHP.
Which of these you use is up to you. There are advantages and disadvantages to both. Using the full connection string means that you do NOT require an ODBC.INI file to access the database. However, if you move the datasource, or change the port on which the RDBMS server listens, you will have to modify every call to the odbc_connect/pconnect function.
The choice is yours...
Empress Installation: In order to add the Empress interface to PHP you require an Empress RDBMS with the Empress Connectivity option. If your PHP installation is on the same platform as the RDBMS then setting EMPRESS_PATH to the installation directory will automatically locate the Empress ODBC client driver. However, if the PHP installation is on a separate platform from the RDBMS you will also require an ODBC client on that platform, and you will need to specify the location of the driver when configuring the PHP installation.
2. Obtaining PHP
1 Where can I obtain PHP?
You can download PHP from any of the members of the PHP network of sites. These can be found at http://www.php.net/. You can also use anonymous CVS to get the absolute latest version of the source. For more information, go to http://cvs.php.net.
2 Are pre-compiled binary versions available?
Yes, although they are not always up to date. The Windows binary is generally current, but the Unix binaries lag behind and are only available for certain platforms.
3 Where can I get libraries needed to compile some of the optional PHP extensions?
Note: Those marked with * are not thread-safe libraries, and should not be used with PHP as a server module in the multi-threaded Windows web servers (IIS, Netscape). This does not matter in Unix environments, yet.
· LDAP (unix): ftp://ftp.openldap.org/pub/openldap/openldap-stable.tgz
· LDAP* (unix): ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z
· LDAP (unix/win): Netscape Directory (LDAP) SDK 1.1 There is also a free LDAP server at: ftp://ftp.critical-angle.com/pub/cai/slapd/.
· Berkeley DB2 (Unix/Win): http://www.sleepycat.com/
· SNMP* (Unix): http://www.ece.ucdavis.edu/ucd-snmp/ (Note: PHP uses the native SNMP interface in Windows.)
· GD* (Unix/Win): http://www.boutell.com/gd/#buildgd
· mSQL* (Unix): http://www.hughes.com.au/
· mSQL* (Win) : MSQL PC Home Page
· MySQL (Unix): http://www.mysql.com/
· IMAP* (Win/Unix): ftp://ftp.cac.washington.edu/imap/old/imap-4.5.tar.Z
· Sybase-CT* (Linux, libc5): Available locally
· FreeType (libttf): http://www.freetype.org/
· ZLib (Unix/Win32): http://www.cdrom.com/pub/infozip/zlib/
· expat XML parser (Unix/Win32): http://www.jclark.com/xml/expat.html
· PDFLib: http://www.pdflib.com
· mcrypt: ftp://argeas.cs-net.gr/pub/unix/mcrypt/
· mhash: http://sasweb.de/mhash/
· t1lib: http://www.neuroinformatik.ruhr-uni-bochum.de/ini/PEOPLE/rmz/t1lib/t1lib.html
· dmalloc: http://www.dmalloc.com/
· aspell: http://metalab.unc.edu/kevina/aspell/aspell-.26.2.tar.gz
· Readline: ftp://prep.ai.mit.edu/pub/gnu/readline/
4 How do I get these libraries to work?
You will need to follow instructions provided with the library. Some of these libraries are detected automatically when you run the 'configure' script of PHP (such as the GD library), and others you will have to enable using '--with-EXTENSION' options to 'configure'. Run 'configure --help' for a listing of these.
5 I got the latest version of the PHP source code from the CVS repository on my Windows 95/NT machine, what do I need to compile it?
First, you will need Microsoft Visual C++ v6 (v5 may do it also, but we do it with v6), and you will need to download the support files. You will need to unzip this file (which has subdirectories, so make sure your unzip program keeps them) into the win32 subdirectory of the source distribution.
6 Where do I find the Browser Capabilities File?
You can find PHP's own browscap.ini file at http://php.netvision.net.il/browscap/. There is also another browscap.ini file at http://www.cyscape.com/asp/browscap/.
3. Installation
To install PHP, follow the instructions in the INSTALL file located in the distribution. Windows 95 and NT users should also read the README.WIN32 file.
If you are trying to install PHP for use with Netscape's web server on Unix see: http://www.webgenx.com/php/phpnes.php3
1 Where should my php3.ini file be located?
By default on UNIX it should be in /usr/local/lib. Most people will want to change this at compile-time with the --with-config-file-path flag. You would, for example, set it to something like:
--with-config-file-path=/etc
And then you would copy php3.ini-dist from the distribution to /etc/php3.ini and edit it to make any local changes you want.
2 I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here?
· Assuming you installed Apache PHP completely with RPMS, you need to uncomment or add some or all of the following lines in your http.conf file:
# Extra Modules
AddModule mod_php.c
AddModule mod_php3.c
AddModule mod_perl.c
# Extra Modules
LoadModule php_module modules/mod_php.so
LoadModule php3_module modules/libphp3.so
LoadModule perl_module modules/libperl.so
· And add:
AddType application/x-httpd-php3 .php3
To the global properties, or to the properties of the VirtualDomain you want to have PHP support added to.
3 I installed PHP using RPMS, but it doesn't compile with the database support I need! What's going on here?
Due to the way PHP is currently built, it is not easy to build a complete flexible PHP RPM. This issue will be addressed in PHP4. For PHP, we currently suggest you use the mechanism described in the INSTALL.REDHAT file in the PHP distribution. If you insist on using an RPM version of PHP, read on...
Currently the RPM packagers are setting up the RPMS to install without database support to simplify installations AND because RPMS use /usr/ instead of the standard /usr/local/ directory for files. You need to tell the RPM spec file which databases to support and the location of the top-level
This example will explain the process of adding support for the popular MySQL database server, using the mod installation for Apache.
Of course all of this information can be adjusted for any database server that PHP supports. I will assume you installed MySQL and Apache completely with RPMS for this example as well. of your database server.
· First remove mod_php3
rpm -e mod_php3
· Then get the source rpm and INSTALL it, NOT --rebuild
rpm -Uvh mod_php3-3.0.5-2.src.rpm
· Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
In the %build section add the database support you want, and the path.
For MySQL you would add --with-mysql=/usr \
The %build section will look something like this:
./configure --prefix=/usr \
--with-apxs=/usr/sbin/apxs \
--with-config-file-path=/usr/lib \
--enable-debug=no \
--enable-safe-mode \
--with-exec-dir=/usr/bin \
--with-mysql=/usr \
--with-system-regex
· Once this modification is made then build the binary rpm as follows:
rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
· Then install the rpm
rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
Make sure you restart Apache, and you now have PHP with MySQL support using RPM's. Note that it is probably much easier to just build from the distribution tarball of PHP and follow the instructions in INSTALL.REDHAT found in that distribution.
4. Build Problems
1 I got the latest version of PHP using the anonymous CVS service, but there's no configure script!
You have to have the GNU autoconf package installed so you can generate the configure script from configure.in. Just run make -f build.mk in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the --enable-maintainer-mode option, the configure script will not automatically get rebuilt when the configure.in file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or config.status is run.)
2 I'm having problems configuring PHP to work with Apache. It says it can't find httpd.h, but it's right where I said it is!
You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify '--with-apache=/path/to/apache' and not '--with-apache=/path/to/apache/src'.
3 When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package!
You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as:
CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
If you're using a csh-variant for your login shell (why?), it would be:
env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
4 When it is compiling the file language-parser.tab.c, it gives me errors that say 'yytname undeclared'.
You need to update your version of Bison. You can find the latest version at ftp://prep.ai.mit.edu/pub/gnu/.
5 When I run 'make', it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files.
Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running "cp *.o functions" and then re-running 'make' to see if that helps. If it does, you should really upgrade to a recent version of GNU make.
6 When linking PHP, it complains about a number of undefined references.
Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included.
If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the INSTALL file that comes with the distribution for more information.
Some people have also reported that they had to add '-ldl' immediately following 'libphp3.a' when linking with Apache.
7 I can't figure out how to build PHP with Apache 1.3.
This is actually quite easy. Follow these steps carefully:
· Grab the latest Apache 1.3 distribution from www.apache.org.
· Ungzip and untar it somewhere, for example /usr/local/src/apache-1.3.
· Compile PHP by first running ./configure --with-apache=//apache-1.3 (substitute for the actual path to your apache-1.3 directory.
· Type 'make' followed by 'make install' to build PHP and copy the necessary files to the Apache distribution tree.
· Change directories into to your //apache-1.3/src directory and edit the Configuration file. At the end of the file, add: AddModule modules/php3/libphp3.a.
· Type: './Configure' followed by 'make'.
· You should now have a PHP-enabled httpd binary!
Note: You can also use the new Apache ./configure script. See the instructions in the README.configure file which is part of your Apache distribution. Also have a look at the INSTALL file in the PHP distribution.
8 I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file. Help!
This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help:
· Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: /path/to/binary/httpd -l
If you don't see mod_php3.c listed then you are not running the right binary. Find and install the correct binary.
· Make sure you have added the correct Mime Type to one of your Apache .conf files. It should be: AddType application/x-httpd-php3 .php3
Also make sure that this AddType line is not hidden away inside a or block which would prevent it from applying to the location of your test script.
· Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly.
9 It says to use: --activate-module=src/modules/php3/libphp3.a, but that file doesn't exist, so I changed it to --activate-module=src/modules/php3/libmodphp3.a and it doesn't work!? What's going on?
Well, you decided to try to outsmart the people who wrote those nice step-by-step instructions for you and you have now discovered that these people cannot be outsmarted. The libphp3.a file is not supposed to exist. The Apache build process will create it.
10 When I try to build Apache with PHP as a static module using --activate-module=src/modules/php3/libphp3.a it tells me that my compiler is not ANSI compliant.
This is a crappy error message and has been fixed in Apache-1.3.10 (not available yet). For now, go and edit the src/Configure file in the Apache source directory and down around line 2140 you will find a line that looks like this:
if ./helpers/TestCompile sanity; then
Change this line to be this:
if ./helpers/TestCompile -v sanity; then
and now re-run the Apache configure script. It will now show you the actual errors that caused your build to fail. It is usually due to a missing library.
11 When I try to build PHP using --with-apxs I get strange error messages
There are two things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Edit your apxs (sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs) and check for these lines:
my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
If this is what you see, you have found your problem. Change these lines to say:
my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl
my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = q(-shared);# substituted via Makefile.tmpl
The second possible problem should only be an issue on RedHat-6.1. The apxs script RedHat ships is broken. Look for this line:
my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install
If you see the above line, change it to this:
my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install
5. Using PHP
1 I would like to write a generic PHP script that can handle data coming from any form. How do I know which POST method variables are available?
Make sure that the track_vars feature is enabled in your php3.ini file. If you compiled PHP with "--enable-track-vars" it will be on by default. Alternatively you can enable it at run-time on a per-script basis by putting at the top of your file. When track_vars is on, it creates three associative arrays. $HTTP_GET_VARS, $HTTP_POST_VARS and $HTTP_COOKIE_VARS. So, to write a generic script to handle POST method variables you would need something similar to the following:
while (list($var, $value) = each($HTTP_POST_VARS)) {
echo "$var = $value
\n";
}
2 I need to convert all single-quotes (') to a backslash followed by a single-quote. How can I do this with a regular expression?
First off, take a look at the addslashes() function. It will do exactly what you want. You should also have a look at the magic_quotes_gpc directive in your php3.ini file.
The ereg_replace magic you're looking for, however, is simply:
$escaped = ereg_replace("'", "\\'", $input);
3 When I do the following, the output is printed in the wrong order:
function myfunc($argument) {
echo $argument + 10;
}
$variable = 10;
echo "myfunc($variable) = " . myfunc($variable);
What's going on?
To be able to use the results of your function in an expression (such as concatenating it with other strings in the example above), you need to return the value, not echo it.
4 Hey, what happened to my newlines in:
1
2
In PHP, the ending for a block of code is either "?>" or "?>\n" (where \n means a newline). This means that you need to insert an extra newline after each block of PHP code in the above example.
Why does PHP do this? Because when formatting normal HTML, this usually makes your life easier because you don't want that newline, but you'd have to create extremely long lines or otherwise make the raw page source unreadable to achieve that effect.
5 I need to access information in the request header directly. How can I do this?
The getallheaders() function will do this if you are running PHP as a module. So, the following bit of code will show you all the request headers:
$headers = getallheaders();
for(reset($headers); $key = key($headers); next($headers)) {
echo "headers[$key] = ".$headers[$key]."
\n";
}
6 When I try to use authentication with IIS I get 'No Input file specified'
The security model of IIS is at fault here. This is a problem common to all CGI programs running under IIS. A workaround is to create a plain HTML file (not parsed by php) as the entry page into an authenticated directory. Then use a META tag to redirect to the PHP page, or have a link to the PHP page. PHP will then recognize the authentication correctly. When the ISAPI module is ready, this will no longer be a problem. This should not effect other NT web servers. For more information, see: http://support.microsoft.com/support/kb/articles/q160/4/22.asp.
7 I've followed all the instructions, but still can't get PHP and IIS to work together!
Make sure any user who needs to run a PHP script has the rights to run php.exe! IIS uses an anonymous user which is added at the time IIS is installed. This user needs rights to php.exe. Also, any authenticated user will also need rights to execute php.exe. And for IIS4 you need to tell it that PHP is a script engine.
8 My PHP script works on IE and Lynx, but on Netscape some of my output is missing. When I do a "View Source" I see the content in IE but not in Netscape. Even when I telnet to port 80 directly the correct content shows up. How can this be? PHP is server-side and my browser can't possibly know that the content it is seeing is generated by PHP, so what is going on?
Very good question! ;) This is a tricky little issue and it has come up twice in the past month as of this writing. Both times I ended up spending a good 20 minutes trying to figure out what the heck was going on. The answer is that both IE and Lynx ignore any NULs (\0) in the HTML stream. Netscape does not. The best way to check for this is to compile the command-line version of PHP (also known as the CGI version) and run your script from the command line and pipe it through 'od -c' and look for any \0 characters. (If you are on Windows you need to find an editor or some other program that lets you look at binary files) When Netscape sees a NUL in a file it will typically not output anything else on that line whereas both IE and Lynx will. If this issue has bitten you, congratulations! You are not alone.
9 How do I get all the results from a SELECT MULTIPLE HTML tag?
The SELECT MULTIPLE tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. ie.
tag, but the $foo.x and $foo.y variables aren't available. Where are they?
When submitting a form, it is possible to use an image instead of the standard submit button with a tag like:
When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables: foo.x and foo.y.
Because $foo.x and $foo.y are invalid variable names in PHP, they are automagically converted to $foo_x and $foo_y. That is, the periods are replaced with underscores.
6. New Features
1 I saw PHP offers persistent database connections. What does that mean?
Persistent connections are SQL links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable).
People who aren't thoroughly familiar with the way web servers work and distribute the load may mistake persistent connects for what they're not. In particular, they do not give you an ability to open 'user sessions' on the same SQL link, they do not give you an ability to build up a transaction efficently, and they don't do a whole lot of other things. In fact, to be extremely clear about the subject, persistent connections don't give you any functionality that wasn't possible with their non-persistent brothers.
Why?
This has to do with the way web servers work. There are three ways in which your web server can utilize PHP to generate web pages.
The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP interpreter is created and destroyed for every page request (for a PHP page) to your web server. Because it is destroyed after every request, any resources that it acquires (such as a link to an SQL database server) are closed when it is destroyed. In this case, you do not gain anything from trying to use persistent connections -- they simply don't persist.
The second, and most popular, method is to run PHP as a module in a multiprocess web server, which currently only includes Apache. A multiprocess server typically has one process (the parent) which coordinates a set of processes (its children) who actually do the work of serving up web pages. When each request comes in from a a client, it is handed off to one of the children that is not already serving another client. This means that when the same client makes a second request to the server, it may be serviced by a different child process than the first time. What a persistent connection does for you in this case it make it so each child process only needs to connect to your SQL server the first time that it serves a page that makes us of such a connection. When another page then requires a connection to the SQL server, it can reuse the connection that child established earlier.
The last method is to use PHP as a plug-in for a multithreaded web server. Currently this is only theoretical -- PHP does not yet work as a plug-in for any multithreaded web servers. Work is progressing on support for ISAPI, WSAPI, and NSAPI (on Windows), which will all allow PHP to be used as a plug-in on multithreaded servers like Netscape FastTrack, Microsoft's Internet Information Server (IIS), and O'Reilly's WebSite Pro. When this happens, the behavior will be essentially the same as for the multiprocess model described before.
If persistent connections don't have any added functionality, what are they good for?
The answer here is extremely simple -- efficiency. Persistent connections are good if the overhead to create a link to your SQL server is high. Whether or not this overhead is really high depends on many factors. Like, what kind of database it is, whether or not it sits on the same computer on which your web server sits, how loaded the machine the SQL server sits on is and so forth. The bottom line is that if that connection overhead is high, persistent connections help you considerably. They cause the child process to simply connect only once for its entire lifespan, instead of every time it processes a page that requires connecting to the SQL server. This means that for every child that opened a persistent connection will have its own open persistent connection to the server. For example, if you had 20 different child processes that ran a script that made a persistent connection to your SQL server, you'd have 20 different connections to the SQL server, one from each child.
An important summary. Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should always be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It may (and probably will) change the efficiency of the script, but not its behavior!
7. Common Problems
1 I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here?
This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like:
· Stop your httpd processes
· gdb httpd
· > run -X -f /path/to/httpd.conf
· Then fetch the URL causing the problem with your browser
· If you are getting a core dump, gdb should inform you of this now
· type: bt
· Send the resulting backtrace to php-dev@lists.php.net
If your script uses the regular expression functions (ereg() and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. (This should happen automatically with PHP and Apache 1.3.x)
2 I'm trying to access one of the standard CGI variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined function, and it can't seem to find it. What's wrong?
Environment variables are now normal global variables, so you must either declare them as global variables in your function (by using "global $DOCUMENT_ROOT;", for example) or by using the global variable array (ie, "$GLOBALS["DOCUMENT_ROOT"]".
3 I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions?
No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem.
4 I think I found a bug! Who should I tell?
You should go to the PHP Bug Database and make sure the bug isn't a known bug. If you don't see it in the database, use the reporting form to report the bug. It is important to use the bug database instead of just sending an email to one of the mailing lists because the bug will have a tracking number assigned and it will then be possible for you to go back later and check on the status of the bug. The bug database can be found at http://bugs.php.net.
8. Migrating from PHP2 to PHP3
1 When I add two strings together and then echo it, it echoes zero instead of the concatenation of the two strings! What's going on? Wouldn't it be great if adding two strings just concatenated them together?
PHP3 does not support the overloading of the addition operator for strings because values that arrive via the GET and POST methods and from databases are always stored as strings. This means that if the plus operator were overloaded to concatenate strings, you could add what you thought were two numbers and get the wrong result! (For example, "4" + "5" would be equal to "45".) One way around this would be to explicitly type-cast one or both of the operands, which is what PHP/FI 2 did.
This has been simplified in PHP3 by the addition of a real string concatenation operator. If you want to "add" two strings together, just write it like: "this" . "that" which will result in the string "thisthat".
The answer to the final part of the question is an emphatic no. Operator overloading can be a source of great confusion, especially when variables aren't very strongly typed to begin with, as they are in PHP3.
2 When I use the chmod(), umask(), or mkdir() functions, the permissions are wrong!
Unlike PHP/FI 2, PHP3 does not interpret the numeric arguments for these functions any differently than for any other function, which means you need to pass in an octal value if you are specifying an octal number, such as:
chmod($myfile, 0600);
not
chmod($myfile, 600);
3 I converted my script from PHP/FI 2.0 to PHP3 syntax, but now it just hangs! When I looked at the processes running on my server, there was one process that was chewing up all of the CPU cycles!
You probably missed the semi-colon on a while (condition); statement. This will cause PHP3 to spin out of control because it is simply executing an empty body for your while loop! Change the semi-colon to a colon and it should work correctly.
4 My user-functions don't work any more! I get a "Parse error (expecting '('" on the first line of the function.
PHP3's function declaration now resembles C function declarations, so your function should look like:
function printsum($a, $b) {
echo $a + $b;
}
You can also use old-style function declarations by use the 'old_function' designation, like so:
old_function printsum $a, $b (
echo $a + $b;
);
5 What happened to the securevar() function that was in PHP2? How can I make sure that a GET-method variable does not overwrite a POST-method one?
The securevar() function in PHP2 was a badly named function. It gave the impression that when used the POST-method was secure. It is not. It is only slightly more difficult to fake POST-method variables than GET-method ones.
$foo = $HTTP_POST_VARS["foo"];
PHP Interview Questions - 3
I. How can we send mail using JavaScript?
II. How can we repair a MySQL table?
III. What are the advantages of stored procedures, triggers, indexes?
IV. What is the maximum length of a table name, database name, and fieldname in MySQL?
V. How many values can the SET function of MySQL take?
VI. What are the other commands to know the structure of table using MySQL commands except explain command?
VII. How many tables will create when we create table, what are they?
VIII. What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain?
IX. What is maximum size of a database in MySQL?
X. Give the syntax of Grant and Revoke commands?
XI. What is Normalization?
XII. Suppose your Zend engine supports the mode Then how can u configure your PHP Zend engine to support mode ?
XIII. Shopping cart online validation i.e. how can we configure Paypal, etc.?
XIV. What is meant by nl2br()?
XV. Draw the architecture of Zend engine?
XVI. What are the current versions of apache, PHP, and mysql?
XVII. What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
XVIII. How can we encrypt and decrypt a data present in a mysql table using mysql?
XIX. How can we encrypt the username and password using PHP?
XX. What are the features and advantages of object-oriented programming?
XXI. What are the differences between procedure-oriented languages and object-oriented languages?
XXII. What is the use of friend function?
XXIII. What are the differences between public, private, protected, static, transient, final and volatile?
XXIV. How can we increase the execution time of a PHP script?
XXV. How can we take a backup of a mysql table and how can we restore it. ?
XXVI. How can we optimize or increase the speed of a mysql select query?
XXVII. How many ways can we get the value of current session id?
XXVIII. How can we destroy the session, how can we unset the variable of a session?
XXIX. How can we destroy the cookie?
XXX. How many ways we can pass the variable through the navigation between the pages?
XXXI. What is the difference between ereg_replace() and eregi_replace()?
XXXII. What are the different functions in sorting an array?
XXXIII. How can we know the count/number of elements of an array?
XXXIV. What is the PHP predefined variable that tells the What types of images that PHP supports?
XXXV. How can I know that a variable is a number or not using a JavaScript?
XXXVI. List out some tools through which we can draw E-R diagrams for mysql.
XXXVII. How can I retrieve values from one database server and store them in other database server using PHP?
XXXVIII. List out the predefined classes in PHP?
XXXIX. How can I make a script that can be bilanguage (supports English, German)?
XL. What are the difference between abstract class and interface?
XLI. How can we find the number of rows in a table using MySQL?
XLII. How can we find the number of rows in a result set using PHP?
XLIII. How many ways we can we find the current date using MySQL?
XLIV. What are the advantages and disadvantages of Cascading Style Sheets?
XLV. What type of inheritance that PHP supports?
XLVI. How can increase the performance of MySQL select query?
XLVII. What are the advantages/disadvantages of MySQL and PHP?
XLVIII. What is the difference between GROUP BY and ORDER BY in Sql?
XLIX. What is the difference between char and varchar data types?
L. What is the functionality of md5 function in PHP?
LI. How can I load data from a text file into a table?
LII. How can we know the number of days between two given dates using MySQL?
LIII. How can we know the number of days between two given dates using PHP?
LIV. How can we change the name of a column of a table?
LV. How can we change the name and data type of a column of a table?
LVI. What are the differences between drop a table and truncate a table?
LVII. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
LVIII. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
LIX. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
LX. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
LXI. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
LXII. A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?
LXIII. What is MIME?
LXIV. What is PEAR in PHP?
LXV. How can I use the COM components in PHP?
LXVI. How can I load the DLLs dynamically?
LXVII. How many ways we can give the output to a browser?
LXVIII. How can we know that a session is started or not?
LXIX. What is the default session time in PHP and how can I change it?
LXX. What changes I have to done in PHP.ini file for file uploading?
LXXI. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
LXXII. How can I set a cron and how can i execute it in Unix, Linux, and windows?
LXXIII. Steps for the payment gateway processing?
LXXIV. How many ways I can register the variables into session?
LXXV. Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
LXXVI. How many ways I can redirect a PHP page?
LXXVII. List out different arguments in PHP header function?
LXXVIII. What type of headers have to add in the mail function in which file a attached?
LXXIX. What is the difference between
LXXX. What are the differences between include() and include_once() functions?
LXXXI. Describe the importance of database abstraction layers in PHP and database connection?
LXXXII. Explain MySQL optimization?
LXXXIII. What is the difference between using copy() and move() function in PHP file uploading?
LXXXIV. What is the difference between Reply-to and Return-path in the headers of a mail function?
LXXXV. Explain about Type Juggling in PHP?
LXXXVI. How can I get the only name of the current executing file?
LXXXVII. How can I embed a Java program in PHP file and what changes have to be done in PHP.ini file?
LXXXVIII. How can I find what type of images that the PHP version supports?
LXXXIX. 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?
XC. Who is the father of PHP and explain the changes in PHP versions?
XCI. How can we submit a form without a submit button?
XCII. In how many ways we can retrieve the date in the result set of mysql using PHP?
XCIII. What is the difference between mysql_fetch_object and mysql_fetch_array?
XCIV. What is the difference between $message and $$message?
XCV. How can we extract string ‘techinterviews.com ‘ from a string ‘http://www.techinterviews.com’ using regular expression of PHP?
XCVI. How can we create a database using PHP and mysql?
XCVII. What are the differences between require and include, include_once?
XCVIII. Can we use include (”techinterviews.php”) two times in a PHP page “makeit.PHP”?
XCIX. 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)) ?
C. Functions in IMAP, POP3 AND LDAP?
CI. How can I execute a PHP script using command line?
CII. What are the different types of errors in PHP?
CIII. What is the functionality of the function strstr and stristr?
CIV. What are the differences between PHP 3 and PHP 4 and PHP 5?
CV. How can we convert asp pages to PHP pages?
CVI. What is the functionality of the function htmlentities?
CVII. How can we get second of the current time using date function?
CVIII. How can we convert the time zones using PHP?
CIX. What is meant by urlencode and urldocode?
CX. What is the difference between the functions unlink and unset?
CXI. How can we register the variables into a session?
CXII. How can we get the properties (size, type, width, height) of an image using PHP image functions?
CXIII. How can we get the browser properties using PHP?
CXIV. What is the maximum size of a file that can be uploaded using PHP and how can we change this?
II. How can we repair a MySQL table?
III. What are the advantages of stored procedures, triggers, indexes?
IV. What is the maximum length of a table name, database name, and fieldname in MySQL?
V. How many values can the SET function of MySQL take?
VI. What are the other commands to know the structure of table using MySQL commands except explain command?
VII. How many tables will create when we create table, what are they?
VIII. What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain?
IX. What is maximum size of a database in MySQL?
X. Give the syntax of Grant and Revoke commands?
XI. What is Normalization?
XII. Suppose your Zend engine supports the mode Then how can u configure your PHP Zend engine to support mode ?
XIII. Shopping cart online validation i.e. how can we configure Paypal, etc.?
XIV. What is meant by nl2br()?
XV. Draw the architecture of Zend engine?
XVI. What are the current versions of apache, PHP, and mysql?
XVII. What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
XVIII. How can we encrypt and decrypt a data present in a mysql table using mysql?
XIX. How can we encrypt the username and password using PHP?
XX. What are the features and advantages of object-oriented programming?
XXI. What are the differences between procedure-oriented languages and object-oriented languages?
XXII. What is the use of friend function?
XXIII. What are the differences between public, private, protected, static, transient, final and volatile?
XXIV. How can we increase the execution time of a PHP script?
XXV. How can we take a backup of a mysql table and how can we restore it. ?
XXVI. How can we optimize or increase the speed of a mysql select query?
XXVII. How many ways can we get the value of current session id?
XXVIII. How can we destroy the session, how can we unset the variable of a session?
XXIX. How can we destroy the cookie?
XXX. How many ways we can pass the variable through the navigation between the pages?
XXXI. What is the difference between ereg_replace() and eregi_replace()?
XXXII. What are the different functions in sorting an array?
XXXIII. How can we know the count/number of elements of an array?
XXXIV. What is the PHP predefined variable that tells the What types of images that PHP supports?
XXXV. How can I know that a variable is a number or not using a JavaScript?
XXXVI. List out some tools through which we can draw E-R diagrams for mysql.
XXXVII. How can I retrieve values from one database server and store them in other database server using PHP?
XXXVIII. List out the predefined classes in PHP?
XXXIX. How can I make a script that can be bilanguage (supports English, German)?
XL. What are the difference between abstract class and interface?
XLI. How can we find the number of rows in a table using MySQL?
XLII. How can we find the number of rows in a result set using PHP?
XLIII. How many ways we can we find the current date using MySQL?
XLIV. What are the advantages and disadvantages of Cascading Style Sheets?
XLV. What type of inheritance that PHP supports?
XLVI. How can increase the performance of MySQL select query?
XLVII. What are the advantages/disadvantages of MySQL and PHP?
XLVIII. What is the difference between GROUP BY and ORDER BY in Sql?
XLIX. What is the difference between char and varchar data types?
L. What is the functionality of md5 function in PHP?
LI. How can I load data from a text file into a table?
LII. How can we know the number of days between two given dates using MySQL?
LIII. How can we know the number of days between two given dates using PHP?
LIV. How can we change the name of a column of a table?
LV. How can we change the name and data type of a column of a table?
LVI. What are the differences between drop a table and truncate a table?
LVII. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
LVIII. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
LIX. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
LX. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
LXI. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
LXII. A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?
LXIII. What is MIME?
LXIV. What is PEAR in PHP?
LXV. How can I use the COM components in PHP?
LXVI. How can I load the DLLs dynamically?
LXVII. How many ways we can give the output to a browser?
LXVIII. How can we know that a session is started or not?
LXIX. What is the default session time in PHP and how can I change it?
LXX. What changes I have to done in PHP.ini file for file uploading?
LXXI. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?
LXXII. How can I set a cron and how can i execute it in Unix, Linux, and windows?
LXXIII. Steps for the payment gateway processing?
LXXIV. How many ways I can register the variables into session?
LXXV. Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
LXXVI. How many ways I can redirect a PHP page?
LXXVII. List out different arguments in PHP header function?
LXXVIII. What type of headers have to add in the mail function in which file a attached?
LXXIX. What is the difference between
LXXX. What are the differences between include() and include_once() functions?
LXXXI. Describe the importance of database abstraction layers in PHP and database connection?
LXXXII. Explain MySQL optimization?
LXXXIII. What is the difference between using copy() and move() function in PHP file uploading?
LXXXIV. What is the difference between Reply-to and Return-path in the headers of a mail function?
LXXXV. Explain about Type Juggling in PHP?
LXXXVI. How can I get the only name of the current executing file?
LXXXVII. How can I embed a Java program in PHP file and what changes have to be done in PHP.ini file?
LXXXVIII. How can I find what type of images that the PHP version supports?
LXXXIX. 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?
XC. Who is the father of PHP and explain the changes in PHP versions?
XCI. How can we submit a form without a submit button?
XCII. In how many ways we can retrieve the date in the result set of mysql using PHP?
XCIII. What is the difference between mysql_fetch_object and mysql_fetch_array?
XCIV. What is the difference between $message and $$message?
XCV. How can we extract string ‘techinterviews.com ‘ from a string ‘http://www.techinterviews.com’ using regular expression of PHP?
XCVI. How can we create a database using PHP and mysql?
XCVII. What are the differences between require and include, include_once?
XCVIII. Can we use include (”techinterviews.php”) two times in a PHP page “makeit.PHP”?
XCIX. 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)) ?
C. Functions in IMAP, POP3 AND LDAP?
CI. How can I execute a PHP script using command line?
CII. What are the different types of errors in PHP?
CIII. What is the functionality of the function strstr and stristr?
CIV. What are the differences between PHP 3 and PHP 4 and PHP 5?
CV. How can we convert asp pages to PHP pages?
CVI. What is the functionality of the function htmlentities?
CVII. How can we get second of the current time using date function?
CVIII. How can we convert the time zones using PHP?
CIX. What is meant by urlencode and urldocode?
CX. What is the difference between the functions unlink and unset?
CXI. How can we register the variables into a session?
CXII. How can we get the properties (size, type, width, height) of an image using PHP image functions?
CXIII. How can we get the browser properties using PHP?
CXIV. What is the maximum size of a file that can be uploaded using PHP and how can we change this?
PHP Interview Questions - 2
62. How many tables will create when we create table, what are they?
3 tables will create when we create table. They are
The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,
63. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?
In MySql, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names that begin with 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,
64. What is maximum size of a database in mysql?
If the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint.
The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. If the time required to open a file in the directory increases significantly as the number of files increases, database performance can be adversely affected.
The amount of available disk space limits the number of tables.
MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage engine in MySQL 3.23, the maximum table size was increased to 65536 terabytes (2567 – 1 bytes). With this larger allowed table size, the maximum effective table size for MySQL databases is usually determined by operating system constraints on file sizes, not by MySQL internal limits.
The InnoDB storage engine maintains InnoDB tables within a tablespace that can be created from several files. This allows a table to exceed the maximum individual file size. The tablespace can include raw disk partitions, which allows extremely large tables. The maximum tablespace size is 64TB.
The following table lists some examples of operating system file-size limits. This is only a rough guide and is not intended to be definitive. For the most up-to-date information, be sure to check the documentation specific to your operating system.
Operating System File-size Limit
Linux 2.2-Intel 32-bit 2GB (LFS: 4GB)
Linux 2.4+ (using ext3 filesystem) 4TB
Solaris 9/10 16TB
NetWare w/NSS filesystem 8TB
Win32 w/ FAT/FAT32 2GB/4GB
Win32 w/ NTFS 2TB (possibly larger)
MacOS X w/ HFS+ 2TB
65. Give the syntax of Grant and Revoke commands?
The generic syntax for grant is as following
> GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY [password]
now rights can be
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
We can grant rights on all databse by using *.* or some specific database by database.* or a specific table by database.table_name
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
password is simply the password of user
The generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
66. Explain Normalization concept?
The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).
First Normal Form
The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).
Second Normal Form
Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.
Third Normal Form
I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key, but dependant on another value in the table
67. 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 result
do this
>SELECT [colms],COUNT(*) FROM table_name [where u put conditions];
68. 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";
69. How many ways we can we find the current date using mysql?
SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
70. What are the advantages and disadvantages of CASCADE STYLE SHEETS?
External Style Sheets
Advantages
Can control styles for multiple documents at once
Classes can be created for use on multiple HTML element types in many documents
Selector and grouping methods can be used to apply styles under complex contexts
Disadvantages
An extra download is required to import style information for each document
The rendering of the document may be delayed until the external style sheet is loaded
Becomes slightly unwieldy for small quantities of style definitions
Embedded Style Sheets
Advantages
Classes can be created for use on multiple tag types in the document
Selector and grouping methods can be used to apply styles under complex contexts
No additional downloads necessary to receive style information
Disadvantages
This method can not control styles for multiple documents at once
Inline Styles
Advantages
Useful for small quantities of style definitions
Can override other style specification methods at the local level so only exceptions need to be listed in conjunction with other style methods
Disadvantages
Does not distance style information from content (a main goal of SGML/HTML)
Can not control styles for multiple documents at once
Author can not create or control classes of elements to control multiple element types within the document
Selector grouping methods can not be used to create complex element addressing scenarios
71. What type of inheritance that php supports? Answer: In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
72. How can increase the performance of mysql select query?
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 the last row 2345 then What will happen in
the following conditions
Condition1: Delete all the rows and insert another row then What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then What is the value for this auto incremented field user_pri_id
In general, when you want to make a slow SELECT … WHERE query faster, the first thing to check is whether you can add an index. All references between different tables should usually be done with indexes. You can use the EXPLAIN statement to determine which indexes are used for a SELECT. See section 7.4.5 How MySQL Uses Indexes and section 7.2.1 EXPLAIN Syntax (Get Information About a SELECT).
Some general tips for speeding up queries on MyISAM tables:
To help MySQL optimize queries better, use ANALYZE TABLE or run myisamchk –analyze on a table after it has been loaded with data. This updates a value for each index part that indicates the average number of rows that have the same value. (For unique indexes, this is always 1.) MySQL will use this to decide which index to choose when you join two tables based on a non-constant expression. You can check the result from the table analysis by using SHOW INDEX FROM tbl_name and examining the Cardinality value. myisamchk –description –verbose shows index distribution information.
To sort an index and data according to an index, use myisamchk –sort-index –sort-records=1 (if you want to sort on index 1). This is a good way to make queries faster if you have a unique index from which you want to read all records in order according to the index. Note that the first time you sort a large table this way, it may take a long time.
In both cases let the value for auto increment field be n then next row will have value n+1 i.e. 2346
73. What are the advantages/disadvantages of mysql and php?
Both of them are open source software (so free of cost), support cross platform. php is faster then ASP and JSP.
74. What is the difference between GROUP BY and ORDER BY in Sql?
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]; Tels 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 according to col2 and so on.
GROUP BY [col1],[col2],…,[coln]; Tels DBMS to group results with same value 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
75. What is the difference between char and varchar data types?
char(M) M bytes 0
80. How can we change the name of a column of a table?
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.
81. How can we change the name and data type of a column of a table?
ALTER [IGNORE] TABLE tbl_name
alter_specification [, alter_specification] | CHANGE [COLUMN] old_col_name column_definition
[FIRST|AFTER col_name]
82. 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, and indexes 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).
83. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
Using Html font color tag:
I am Amin
Using tag in CSS:
STRONG {color:red}
So when we use the tag:
I am Amin about this.
Using Class in CSS:
.colorclass
{
color:#FF3399;
font-weight:900;
}
I am Amin
If we use html the modification will be trouble some because we have to change the code of the page. But when we use CSS then it will be easy to change the CSS file and we can get the desired out put.
84. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
When you use the metatag in the header section at the beginning of an HTML Web page, the Web page may still be cached in the Temporary Internet Files folder.
A page that Internet Explorer is browsing is not cached until half of the 64 KB buffer is filled. Usually, metatags are inserted in the header section of an HTML document, which appears at the beginning of the document. When the HTML code is parsed, it is read from top to bottom. When the metatag is read, Internet Explorer looks for the existence of the page in cache at that exact moment. If it is there, it is removed. To properly prevent the Web page from appearing in the cache, place another header section at the end of the HTML ocument. For example:
85. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
86. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
87. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
There is at least 3 ways to logon to a remote server:
Use ssh or telnet if you concern with security
You can also use rlogin to logon to a remote server.
88. Please give a regular _expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example: The regular _expression should match the tag mysqldump -u user -ppassword –opt -full database_name > backupfile.sql
Then move the resulting file(s) to your preferred backup areas. If you require more information on the mysqldump command, then simply check out this URL:www.mysql.com/documentation/mysql
Copy all the relevant table files.
If the server isn't updating anything (or you've deliberately killed mysqld for this purpose) then you can copy all the files with the following extensions in your MySQL data directory:
*.frm
*.myd
*.myi
Make sure you restart the MySQL daemon once you finish copying and downloading the files to your preferred backup areas.
TIP: once you've completed the backup, restart MySQL with the –log-update switch. This will allow you to keep track of all modifications done in the MySQL tables since your last 'dump'.
To restore your dumps, you should either restore to an existing database or create a new database using
shell> mysqladmin create database_name
then issue the following command :
shell> mysql -u user -ppassword database_name
94. What is meant by MIME?
Multipurpose Internet Mail Extensions.
WWW's ability to recognise 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. …
95. What is meant by PEAR in php?
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 users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR 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 people have joined the project since then.
http://pear.php.net/manual/en/introduction.php
96. How can I use the COM components in php?
The COM class provides a framework to integrate (D)COM components into your PHP scripts.
string COM::COM ( string module_name [, string server_name [, int codepage]])
COM class constructor. Parameters:
module_name
name or class-id of the requested component.
server_name
name of the DCOM server from which the component should be fetched. If NULL, localhost is assumed. To allow DCOM com.allow_dcom has to be set to TRUE in php.ini.
codepage
specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL, CP_THREAD_ACP, CP_UTF7 and CP_UTF8.
Usage:
Version}\n"; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff $word->Selection->TypeText("This is a test…"); $word->Documents[1]->SaveAs("Useless test.doc"); //closing word $word->Quit(); //free the object $word->Release(); $word = null; ?>
97. How can I load the dlla€™s dynamically?
98. How many ways we can give the output to a browser?
HTML output
PHP, ASP, JSP, Servlet Function
Script Language output Function
Different Type of embedded Package to output to a browser
99. How can we know that a session is started or not?
a session starts by session_start()function.
this session_start() is always declared in header portion.it always declares first.then we write session_register().
100. What is the default session time in php and how can I change it?
The default session time in php is until closing of browser
101. What changes I have to done in php.ini file for file uploading?
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
102. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both.
mysql_fetch_object ( resource result )
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.
103. How can I set a cron and how can I execute it in Unix, Linux, and windows?
Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it's called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time.
The easiest way to use crontab is via the crontab command.
# crontab –e
This command 'edits' the crontab. Upon employing this command, you will be able to enter the commands that you wish to run. My version of Linux uses the text editor vi. You can find information on using vi here.
The syntax of this file is very important – if you get it wrong, your crontab will not function properly. The syntax of the file should be as follows:
minutes hours day_of_month month day_of_week command
All the variables, with the exception of the command itself, are numerical constants. In addition to an asterisk (*), which is a wildcard that allows any value, the ranges permitted for each field are as follows:
Minutes: 0-59
Hours: 0-23
Day_of_month: 1-31
Month: 1-12
Weekday: 0-6
We can also include multiple values for each entry, simply by separating each value with a comma.
command can be any shell command and, as we will see momentarily, can also be used to execute a Web document such as a PHP file.
So, if we want to run a script every Tuesday morning at 8:15 AM, our mycronjob file will contain the following content on a single line:
15 8 * * 2 /path/to/scriptname
This all seems simple enough, right? Not so fast! If you try to run a PHP script in this manner, nothing will happen (barring very special configurations that have PHP compiled as an executable, as opposed to an Apache module). The reason is that, in order for PHP to be parsed, it needs to be passed through Apache. In other words, the page needs to be called via a browser or other means of retrieving Web content.
For our purposes, I'll assume that your server configuration includes wget, as is the case with most default configurations. To test your configuration, log in to shell. If you're using an RPM-based system (e.g. Redhat or Mandrake), type the following:
# wget –help
If you are greeted with a wget package identification, it is installed in your system.
You could execute the PHP by invoking wget on the URL to the page, like so:
# wget http://www.example.com/file.php
Now, let's go back to the mailstock.php file we created in the first part of this article. We saved it in our document root, so it should be accessible via the Internet. Remember that we wanted it to run at 4PM Eastern time, and send you your precious closing bell report? Since I'm located in the Eastern timezone, we can go ahead and set up our crontab to use 4:00, but if you live elsewhere, you might have to compensate for the time difference when setting this value.
This is what my crontab will look like:
0 4 * * 1,2,3,4,5 wget http://www.example.com/mailstock.php
104. Steps for the payment gateway processing?
An online payment gateway is the interface between your merchant account and your Web site. The online payment gateway allows you to immediately verify credit card transactions and authorize funds on a customer's credit card directly from your Web site. It then passes the transaction off to your merchant bank for processing, commonly referred to as transaction batching
105. How many ways I can register the variables into session?
session_register(); $_SESSION[]; $HTTP_SESSION_VARS[];
106. Explain different types of errors in php (i.e. arguments in error reporting function)?
Three are three types of errors:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.
2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behaviour is to display them to the user when they take place.
107. How many ways I can redirect a php page?
Here are the possible ways of php page redirection.
Using Java script:
'; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http://maosjb.com'); ?>
Using php function:
Header("Location:http://maosjb.com ");
108. List out different arguments in php header function?
void header ( string string [, bool replace [, int http_response_code]])
109. What type of headers have to add in the mail function in which file a attached?
$boundary = '—–=' . md5( uniqid ( rand() ) );
$headers = "From: \"Me\"\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
110. What is the difference between and And which can be preferable?
move_uploaded_file ( string filename, string destination)
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.
116. What is the difference between Reply-to and Return-path in the headers of a mail function?
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 where to delivery the failure notification.
117. Explain about Type Juggling in php?
PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer.
An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined.
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a?
The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined. PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one presented above:
118. How can I get the only name of the current executing file?
119. How can I embed a java programme in php file and what changeshave to be done in php.ini file?
There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment, which is the more stable and efficient solution, or integrate Java support into PHP. The former is provided by a SAPI module that interfaces with the Servlet server, the latter by this Java extension.
The Java extension provides a simple and effective means for creating and invoking methods on Java objects from PHP. The JVM is created using JNI, and everything runs in-process.
Example Code:
getProperty('java.version') . ''; echo 'Java vendor=' . $system->getProperty('java.vendor') . ''; echo 'OS=' . $system->getProperty('os.name') . ' ' . $system->getProperty('os.version') . ' on ' . $system->getProperty('os.arch') . ' '; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); echo $formatter->format(new Java('java.util.Date')); ?>
The behaviour of these functions is affected by settings in php.ini.
Table 1. Java configuration options
Name
Default
Changeable
java.class.path
NULL
PHP_INI_ALL
Name Default Changeable
java.home
NULL
PHP_INI_ALL
java.library.path
NULL
PHP_INI_ALL
java.library
JAVALIB
PHP_INI_ALL
120. How can I find what type of images that the php version supports?
Using Imagetypes() function we can know
Usage:
121. The table tbl_sites contains the following data.
—————————————————–
Userid sitename country
——————————————————
1 sureshbabu indian
2 phpprogrammer andhra
3 php.net usa
4 phptalk.com germany
5 mysql.com usa
6 sureshbabu canada
7 phpbuddy.com pakistan
8. phptalk.com austria
9. phpfreaks.com sourthafrica
10. phpsupport.net russia
11. sureshbabu australia
12. sureshbabu nepal
13. phptalk.com italy
Write a select query that will displayed the duplicated site name and how many times it is duplicated?
SELECT sitename,
COUNT(sitename) AS NumOccurrences
FROM tbl_sites
GROUP BY sitemail
HAVING ( COUNT(sitemail) > 1 )
Or
SELECT sitename
FROM tbl_sites
GROUP BY sitename
HAVING ( COUNT(sitename) = 1 )
122. How can we send mail using JavaScript?
No. You can't send mail using Javascript. But you can execute a client side email client to send the email using mailto: code.
Using clientside email client
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location="mailto:mailid@domain.com?subject="+tdata+"/MYFORM";
return true; }
}
3 tables will create when we create table. They are
The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,
63. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?
In MySql, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names that begin with 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,
64. What is maximum size of a database in mysql?
If the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint.
The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. If the time required to open a file in the directory increases significantly as the number of files increases, database performance can be adversely affected.
The amount of available disk space limits the number of tables.
MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the MyISAM storage engine in MySQL 3.23, the maximum table size was increased to 65536 terabytes (2567 – 1 bytes). With this larger allowed table size, the maximum effective table size for MySQL databases is usually determined by operating system constraints on file sizes, not by MySQL internal limits.
The InnoDB storage engine maintains InnoDB tables within a tablespace that can be created from several files. This allows a table to exceed the maximum individual file size. The tablespace can include raw disk partitions, which allows extremely large tables. The maximum tablespace size is 64TB.
The following table lists some examples of operating system file-size limits. This is only a rough guide and is not intended to be definitive. For the most up-to-date information, be sure to check the documentation specific to your operating system.
Operating System File-size Limit
Linux 2.2-Intel 32-bit 2GB (LFS: 4GB)
Linux 2.4+ (using ext3 filesystem) 4TB
Solaris 9/10 16TB
NetWare w/NSS filesystem 8TB
Win32 w/ FAT/FAT32 2GB/4GB
Win32 w/ NTFS 2TB (possibly larger)
MacOS X w/ HFS+ 2TB
65. Give the syntax of Grant and Revoke commands?
The generic syntax for grant is as following
> GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY [password]
now rights can be
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
We can grant rights on all databse by using *.* or some specific database by database.* or a specific table by database.table_name
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
password is simply the password of user
The generic syntax for revoke is as following
> REVOKE [rights] on [database/s] FROM [username@hostname]
now rights can be as explained above
a) All privileges
b) combination of create, drop, select, insert, update and delete etc.
username@hotsname can be either username@localhost, username@hostname and username@%
where hostname is any valid hostname and % represents any name, the *.* any condition
66. Explain Normalization concept?
The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).
First Normal Form
The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).
Second Normal Form
Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.
Third Normal Form
I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key, but dependant on another value in the table
67. 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 result
do this
>SELECT [colms],COUNT(*) FROM table_name [where u put conditions];
68. 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";
69. How many ways we can we find the current date using mysql?
SELECT CURDATE();
CURRENT_DATE() = CURDATE()
for time use
SELECT CURTIME();
CURRENT_TIME() = CURTIME()
70. What are the advantages and disadvantages of CASCADE STYLE SHEETS?
External Style Sheets
Advantages
Can control styles for multiple documents at once
Classes can be created for use on multiple HTML element types in many documents
Selector and grouping methods can be used to apply styles under complex contexts
Disadvantages
An extra download is required to import style information for each document
The rendering of the document may be delayed until the external style sheet is loaded
Becomes slightly unwieldy for small quantities of style definitions
Embedded Style Sheets
Advantages
Classes can be created for use on multiple tag types in the document
Selector and grouping methods can be used to apply styles under complex contexts
No additional downloads necessary to receive style information
Disadvantages
This method can not control styles for multiple documents at once
Inline Styles
Advantages
Useful for small quantities of style definitions
Can override other style specification methods at the local level so only exceptions need to be listed in conjunction with other style methods
Disadvantages
Does not distance style information from content (a main goal of SGML/HTML)
Can not control styles for multiple documents at once
Author can not create or control classes of elements to control multiple element types within the document
Selector grouping methods can not be used to create complex element addressing scenarios
71. What type of inheritance that php supports? Answer: In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.
72. How can increase the performance of mysql select query?
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 the last row 2345 then What will happen in
the following conditions
Condition1: Delete all the rows and insert another row then What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then What is the value for this auto incremented field user_pri_id
In general, when you want to make a slow SELECT … WHERE query faster, the first thing to check is whether you can add an index. All references between different tables should usually be done with indexes. You can use the EXPLAIN statement to determine which indexes are used for a SELECT. See section 7.4.5 How MySQL Uses Indexes and section 7.2.1 EXPLAIN Syntax (Get Information About a SELECT).
Some general tips for speeding up queries on MyISAM tables:
To help MySQL optimize queries better, use ANALYZE TABLE or run myisamchk –analyze on a table after it has been loaded with data. This updates a value for each index part that indicates the average number of rows that have the same value. (For unique indexes, this is always 1.) MySQL will use this to decide which index to choose when you join two tables based on a non-constant expression. You can check the result from the table analysis by using SHOW INDEX FROM tbl_name and examining the Cardinality value. myisamchk –description –verbose shows index distribution information.
To sort an index and data according to an index, use myisamchk –sort-index –sort-records=1 (if you want to sort on index 1). This is a good way to make queries faster if you have a unique index from which you want to read all records in order according to the index. Note that the first time you sort a large table this way, it may take a long time.
In both cases let the value for auto increment field be n then next row will have value n+1 i.e. 2346
73. What are the advantages/disadvantages of mysql and php?
Both of them are open source software (so free of cost), support cross platform. php is faster then ASP and JSP.
74. What is the difference between GROUP BY and ORDER BY in Sql?
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]; Tels 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 according to col2 and so on.
GROUP BY [col1],[col2],…,[coln]; Tels DBMS to group results with same value 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
75. What is the difference between char and varchar data types?
char(M) M bytes 0
80. How can we change the name of a column of a table?
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.
81. How can we change the name and data type of a column of a table?
ALTER [IGNORE] TABLE tbl_name
alter_specification [, alter_specification] | CHANGE [COLUMN] old_col_name column_definition
[FIRST|AFTER col_name]
82. 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, and indexes 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).
83. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
Using Html font color tag:
I am Amin
Using tag in CSS:
STRONG {color:red}
So when we use the tag:
I am Amin about this.
Using Class in CSS:
.colorclass
{
color:#FF3399;
font-weight:900;
}
I am Amin
If we use html the modification will be trouble some because we have to change the code of the page. But when we use CSS then it will be easy to change the CSS file and we can get the desired out put.
84. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
When you use the metatag in the header section at the beginning of an HTML Web page, the Web page may still be cached in the Temporary Internet Files folder.
A page that Internet Explorer is browsing is not cached until half of the 64 KB buffer is filled. Usually, metatags are inserted in the header section of an HTML document, which appears at the beginning of the document. When the HTML code is parsed, it is read from top to bottom. When the metatag is read, Internet Explorer looks for the existence of the page in cache at that exact moment. If it is there, it is removed. To properly prevent the Web page from appearing in the cache, place another header section at the end of the HTML ocument. For example:
85. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?
86. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?
87. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
There is at least 3 ways to logon to a remote server:
Use ssh or telnet if you concern with security
You can also use rlogin to logon to a remote server.
88. Please give a regular _expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example: The regular _expression should match the tag mysqldump -u user -ppassword –opt -full database_name > backupfile.sql
Then move the resulting file(s) to your preferred backup areas. If you require more information on the mysqldump command, then simply check out this URL:www.mysql.com/documentation/mysql
Copy all the relevant table files.
If the server isn't updating anything (or you've deliberately killed mysqld for this purpose) then you can copy all the files with the following extensions in your MySQL data directory:
*.frm
*.myd
*.myi
Make sure you restart the MySQL daemon once you finish copying and downloading the files to your preferred backup areas.
TIP: once you've completed the backup, restart MySQL with the –log-update switch. This will allow you to keep track of all modifications done in the MySQL tables since your last 'dump'.
To restore your dumps, you should either restore to an existing database or create a new database using
shell> mysqladmin create database_name
then issue the following command :
shell> mysql -u user -ppassword database_name
94. What is meant by MIME?
Multipurpose Internet Mail Extensions.
WWW's ability to recognise 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. …
95. What is meant by PEAR in php?
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 users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR 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 people have joined the project since then.
http://pear.php.net/manual/en/introduction.php
96. How can I use the COM components in php?
The COM class provides a framework to integrate (D)COM components into your PHP scripts.
string COM::COM ( string module_name [, string server_name [, int codepage]])
COM class constructor. Parameters:
module_name
name or class-id of the requested component.
server_name
name of the DCOM server from which the component should be fetched. If NULL, localhost is assumed. To allow DCOM com.allow_dcom has to be set to TRUE in php.ini.
codepage
specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL, CP_THREAD_ACP, CP_UTF7 and CP_UTF8.
Usage:
Version}\n"; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff $word->Selection->TypeText("This is a test…"); $word->Documents[1]->SaveAs("Useless test.doc"); //closing word $word->Quit(); //free the object $word->Release(); $word = null; ?>
97. How can I load the dlla€™s dynamically?
98. How many ways we can give the output to a browser?
HTML output
PHP, ASP, JSP, Servlet Function
Script Language output Function
Different Type of embedded Package to output to a browser
99. How can we know that a session is started or not?
a session starts by session_start()function.
this session_start() is always declared in header portion.it always declares first.then we write session_register().
100. What is the default session time in php and how can I change it?
The default session time in php is until closing of browser
101. What changes I have to done in php.ini file for file uploading?
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
102. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both.
mysql_fetch_object ( resource result )
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.
103. How can I set a cron and how can I execute it in Unix, Linux, and windows?
Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it's called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time.
The easiest way to use crontab is via the crontab command.
# crontab –e
This command 'edits' the crontab. Upon employing this command, you will be able to enter the commands that you wish to run. My version of Linux uses the text editor vi. You can find information on using vi here.
The syntax of this file is very important – if you get it wrong, your crontab will not function properly. The syntax of the file should be as follows:
minutes hours day_of_month month day_of_week command
All the variables, with the exception of the command itself, are numerical constants. In addition to an asterisk (*), which is a wildcard that allows any value, the ranges permitted for each field are as follows:
Minutes: 0-59
Hours: 0-23
Day_of_month: 1-31
Month: 1-12
Weekday: 0-6
We can also include multiple values for each entry, simply by separating each value with a comma.
command can be any shell command and, as we will see momentarily, can also be used to execute a Web document such as a PHP file.
So, if we want to run a script every Tuesday morning at 8:15 AM, our mycronjob file will contain the following content on a single line:
15 8 * * 2 /path/to/scriptname
This all seems simple enough, right? Not so fast! If you try to run a PHP script in this manner, nothing will happen (barring very special configurations that have PHP compiled as an executable, as opposed to an Apache module). The reason is that, in order for PHP to be parsed, it needs to be passed through Apache. In other words, the page needs to be called via a browser or other means of retrieving Web content.
For our purposes, I'll assume that your server configuration includes wget, as is the case with most default configurations. To test your configuration, log in to shell. If you're using an RPM-based system (e.g. Redhat or Mandrake), type the following:
# wget –help
If you are greeted with a wget package identification, it is installed in your system.
You could execute the PHP by invoking wget on the URL to the page, like so:
# wget http://www.example.com/file.php
Now, let's go back to the mailstock.php file we created in the first part of this article. We saved it in our document root, so it should be accessible via the Internet. Remember that we wanted it to run at 4PM Eastern time, and send you your precious closing bell report? Since I'm located in the Eastern timezone, we can go ahead and set up our crontab to use 4:00, but if you live elsewhere, you might have to compensate for the time difference when setting this value.
This is what my crontab will look like:
0 4 * * 1,2,3,4,5 wget http://www.example.com/mailstock.php
104. Steps for the payment gateway processing?
An online payment gateway is the interface between your merchant account and your Web site. The online payment gateway allows you to immediately verify credit card transactions and authorize funds on a customer's credit card directly from your Web site. It then passes the transaction off to your merchant bank for processing, commonly referred to as transaction batching
105. How many ways I can register the variables into session?
session_register(); $_SESSION[]; $HTTP_SESSION_VARS[];
106. Explain different types of errors in php (i.e. arguments in error reporting function)?
Three are three types of errors:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.
2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behaviour is to display them to the user when they take place.
107. How many ways I can redirect a php page?
Here are the possible ways of php page redirection.
Using Java script:
'; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http://maosjb.com'); ?>
Using php function:
Header("Location:http://maosjb.com ");
108. List out different arguments in php header function?
void header ( string string [, bool replace [, int http_response_code]])
109. What type of headers have to add in the mail function in which file a attached?
$boundary = '—–=' . md5( uniqid ( rand() ) );
$headers = "From: \"Me\"\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
110. What is the difference between and And which can be preferable?
move_uploaded_file ( string filename, string destination)
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.
116. What is the difference between Reply-to and Return-path in the headers of a mail function?
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 where to delivery the failure notification.
117. Explain about Type Juggling in php?
PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer.
An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined.
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a?
The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined. PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one presented above:
118. How can I get the only name of the current executing file?
119. How can I embed a java programme in php file and what changeshave to be done in php.ini file?
There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment, which is the more stable and efficient solution, or integrate Java support into PHP. The former is provided by a SAPI module that interfaces with the Servlet server, the latter by this Java extension.
The Java extension provides a simple and effective means for creating and invoking methods on Java objects from PHP. The JVM is created using JNI, and everything runs in-process.
Example Code:
getProperty('java.version') . ''; echo 'Java vendor=' . $system->getProperty('java.vendor') . ''; echo 'OS=' . $system->getProperty('os.name') . ' ' . $system->getProperty('os.version') . ' on ' . $system->getProperty('os.arch') . ' '; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); echo $formatter->format(new Java('java.util.Date')); ?>
The behaviour of these functions is affected by settings in php.ini.
Table 1. Java configuration options
Name
Default
Changeable
java.class.path
NULL
PHP_INI_ALL
Name Default Changeable
java.home
NULL
PHP_INI_ALL
java.library.path
NULL
PHP_INI_ALL
java.library
JAVALIB
PHP_INI_ALL
120. How can I find what type of images that the php version supports?
Using Imagetypes() function we can know
Usage:
121. The table tbl_sites contains the following data.
—————————————————–
Userid sitename country
——————————————————
1 sureshbabu indian
2 phpprogrammer andhra
3 php.net usa
4 phptalk.com germany
5 mysql.com usa
6 sureshbabu canada
7 phpbuddy.com pakistan
8. phptalk.com austria
9. phpfreaks.com sourthafrica
10. phpsupport.net russia
11. sureshbabu australia
12. sureshbabu nepal
13. phptalk.com italy
Write a select query that will displayed the duplicated site name and how many times it is duplicated?
SELECT sitename,
COUNT(sitename) AS NumOccurrences
FROM tbl_sites
GROUP BY sitemail
HAVING ( COUNT(sitemail) > 1 )
Or
SELECT sitename
FROM tbl_sites
GROUP BY sitename
HAVING ( COUNT(sitename) = 1 )
122. How can we send mail using JavaScript?
No. You can't send mail using Javascript. But you can execute a client side email client to send the email using mailto: code.
Using clientside email client
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location="mailto:mailid@domain.com?subject="+tdata+"/MYFORM";
return true; }
}
Subscribe to:
Comments (Atom)