MYSQL 4 does not allow IN (Select ...) .
So what you do is execute a query , generate a long set of values in then execute the query .

Cavet : SQL buffer can over flow

MYSQL Supports ( Select ..... in ( .... ) )

Understanding empty fucntion in PHP

Here is a quick tip:

empty and is_blank


$var = 10;

// Evaluates to true because $var is empty
if (empty($var)) {
'$var is either 0, empty, or not set at all';

PHP easter egg

add ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 to your PHP code and check it out .. should show a sweet dogie or something . This will work only if Expose PHP is on (php.ini) !

Oracle and PHP Tutorial - Easy

PHP Interview Questions Part I

I hope this would be helpful for the jobseekers.

This is "three part" article

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

Get- sends requset in the form of qusery string and post hides the
data, and send directly to system.out

2. Who is the father of php and explain the php versions

Ans: Rasmus Lerdorf

3. How can we submit a form without a submit button

1. image button 2. button. 3. java script form.submit() function

4. How many ways we can retrieve the date in result set of mysql using php

4 ways, 1. mysql_fetch_row. 2. mysql_fetch_array. 3.
mysql_fetch_object 4. mysql_fetch_assoc

5. What is the difference between mysql_fetch_object and mysql_fetch_array

mysql_fetch_object -- Fetch a result row as an object
mysql_fetch_array -- Fetch a result row as an associative array, a
numeric array, or both.

6. What is the difference between $message and $$message

$message- is a varibale. $$message is a variable inside varibale

7. How can we extract string 'abc.com ' from a string 'http://info@abc.com' using regular expression of php


if (eregi ("http://(.*)@(.*)", $line, $add))
echo $add[2];

8. How can we create a database using mysql

mysql_create_db in php. Create database name....

9. What is the differences between require and include, include_once

include: warning require : fatal-error
include_once should be used in cases where the same file might be
included and evaluated more than once during a particular execution of a

10. can we use include("myfile.php") two times in a php age "makeit.php"

yes we can include twice.

11. 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))


12. Functions in IMAP, POP3 AND LDAP

Please check in the manual (some people say RTFM... no offence !)

15. Shopping cart online validation ie how can we configure the Nobel Pay

It is done thru curlfunction card details will be sent to the page in Nobel pay site which is already given to us by them. Only we have to send the parameters which is required for calling that page.

PHP Interview Questions Part II

16. What is meant my nl2br()

Ans: like

19. What are the reasons for selecting lamp(Linux, apache, mysql, php) instead of combination of other software programmes, servers and operating system?

Ans: All are Open-Source and are related internally

20. How can we encrypt and decrypt a data present in a mysqltable using mysql


21. How can we encrypt the username and password using php

Ans: md5() sha1()

22. What are the features and advantages of OBJECT ORIENTED PROGRAMMING

Ans: Encapsulation and inheritence and ploymorphism


Ans: procedural programming executes serially, and OOPS - memory is
alloted when the objects are created. no step by step execution.

24. what is the use of friend function (many say it as array)

Ans: we can use that function any where in the module not necessary to
create an instance of class.

26. What are the different types of errors in php

Ans: Fatal errors, Parse errors......

27. What is the functionality of the function strstr and stristr

Ans: strstr -- Find first occurrence of a string
stristr -- Case-insensitive strstr()

28. What are the differences between PHP 3 and PHP 4 and PHP 5

Ans: Every time they will include some new functionalities and some new

29. How can we convert asp pages to php pages

Ans: There is a saperate tool for that

30. What is the functionality of the function htmlentities

Ans: htmlentities -- Convert all applicable characters to HTML entities

31. How can we get second of the current time using date function?

Ans: today = date("H:i:s");

33. What is meant by urlencode and urldocode

Ans: to encode urls, returns a string in which all non-alphanumeric

PHP Interview Questions Part III

some more interview questions here..

34. What is the difference between the functions unlink and unset

Ans: unlink deletes a file, and unset unset a given variable.

35. How can we register the variables into a session

Ans: session_register("name", "value");

36. How can we get the properties (size, type, width, height) of an image using php image functions

Ans: getimagesize -- Get the size of an image

37. How can we get the browser properties using php

Ans: get_browser -- Tells what the user's browser is capable of

38. What is the maximum size of a file that can be uploaded using php and how can we change this

Ans: upload_max_filesize="size"

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

Ans: set_time_limit -- Limits the maximum execution time

40. How can a take a backup of a mysql table and how can we restore it.

Ans: Backup databasename

41. How can we optimize or increase the speed of a mysql select query

Ans: By indexing columns

42. How many ways can we get the value of current session id?

Ans: by a variable PHPSESSID

43. How can we destroy the session, how can we unset the variable of a session

Ans: session_destroy() to unset a variable session_regirster("name"
,"new value")

44. How can we destroy the cookie

Ans: by seeting its time to a old time

45. How many ways we can pass the variable through the navigation between the pages

Ans: cookies, sessions, hidden variables

46. What is the difference between ereg_replace() and eregi_replace()

Ans: case insensitive

47. What are the different functions in sorting an array
Ans: sort, ksort, asort, usort

48. How can we know the count/number of elements of an array

49. What is the php predefined variable that tells the what types of images that php supports
Ans: count()

Why UML : Reverse engineeredd Diagrams

Just imagine this :

You boss wants you to read 25000 lines of code and wants you to understand what and why each class exists. The solution is this .

Ask for UML design better still generate one from the code .That will give you a fair idea. But of course you will java doc it . Remember one does not replace the other. JavaDoc only tells you what the code does no how they talk to each other . If you have reverse engineered via a decent tool the likely hood is you have an Interaction diagram. So read it .

If this article saved you time just bookmark my blog or place link to it .

Chow then.

Java Server Faces (Whats that ?)

JavaServer Faces technology simplifies building user interfaces for JavaServer applications. Developers of various skill levels can quickly build web applications by: assembling reusable UI components in a page; connecting these components to an application data source; and wiring client-generated events to server-side event handlers.

Currently, Sun is responsible for the reference implementation, which will work with any standard servlet container. They also support JSF in their recently announced NetBeans-based rapid application development tool, Java Studio Creator. Creator 1.0 was recently released at JavaOne in June of 2004.

Sun isn't the only member of the expert group, though. It includes key IDE and J2EE vendors, including IBM, Borland, BEA, Macromedia, Apache Software Foundation, Oracle, and many others. Oracle has announced support for JSF in an upcoming version of JDeveloper. Borland has also announced support, and IBM has also added full support for JSF 1.0 to WebSphere Studio 5.1.2, which is currently available. Most of the other members have made their intentions of supporting JSF known. To keep up with the latest JSF products, check out the products page or subscribe to the products RSS feed.

EJB Roles

These are some roles in the EJB systems. In reality though, one or more of these roles are perforemed by a single individual. However this need not be the case.

Enterprise Bean Provider

Application Assembler


EJB Server Provider:

Orion / BEA etc.

EJB Container Provider
Same as above but the later specs allow loose coupling via XML that is APache we server with BEA Container

System Administrator

Simple : Encrypt passwords in database

The crypt function lets you encrypt text
here is how

= crypt('mypassword'); // let the salt be automatically generated
// do this to encrypt
the password

//use $password in your (insert into.......) code

For retrieval

if (crypt($_REQUEST['pass'], $password) == $password) {
"Password verified!";


Browser Sniffer in PHP

Why should one know what the browser is ?

The broser Javascript is differnt across browsers NetScape vs IE vs Opera. So if you are sending JS for all browsers to the client then its a bad thing because

1) Your server is under more stress.
2) The code will need to resolve the user agent at the client end
3) The cleints might not visit your site again due to the slugginshness!

so this is how you do it :

$b = $HTTP_USER_AGENT; $vers = 0.0;

// detect browser brand and version number
if (eregi('Opera[ \/]([0-9\.]+)' , $b, $a)) {
$type = 'Opera';}
elseif (eregi('Netscape[[:alnum:]]*[ \/]([0-9\.]+)', $b, $a)) {
$type = 'Netscape';}
elseif (eregi('MSIE[ \/]([0-9\.]+)', $b, $a)) {
$type = 'Explorer';}

Hey smart guys , obviously you will use this code in a function or class library right . Keep it maintainable .... right ?

Back Door entry (Hack) -White Ht To phpBB

1st Steps
- Open your phpMyAdmin or any database manager.
- Browse through phpbb_users table (replace phpbb_ with your current prefix)
- Look for your username and select "edit"
- Look for the field user_password

2nd Steps
- Now go to http://www.acecoolco.com/tool_md5.php (This is a password Generator)
- Type your new password in the field
- Copy the code on the row After:

3rd Steps
- Paste the code in the user_password value field
- Press "Go" or submit (depends on your db manager)

2nd Method
If method 1 don't work, try this one

1st Steps
- Register a new account

2nd Steps
- Open your phpMyAdmin or any database manager.
- Browse through phpbb_users table (replace phpbb_ with your current prefix)
- Look for your new username. Click "Edit"
- Change the user level to 1
- Press "Go" or submit (depends on your db manager)

FYI : Note that phpBB user levels
0- Normal User
1- Administrator
2- Moderator


switch ( $action ) {
case ( 'FBI Most Wanted' ) :

case ( 'Most Fuel Efficient Car' ) :

case ( 'Most Expensive Car' ) :

if ( $action == 'first' ) {
} elseif ( $action == 'Most Fuel Efficient Car' ) {
} elseif ( $action == 'Most Expensive Car' ) {

Obviously Switch is a lot cleaner to read !

Zend PHP Certification - How to

Step 1: Purchase a Zend PHP Certification Voucher
Step 2: Schedule to take the exam at one of 3500+ testing centers.
Step 3: Study for the exam using the Zend PHP Certification Study Guide, Zend PHP Certification Practice Test Book, or get a bit of extra help with the Certification Preparation Online Course.
Step 4: Pass the exam! Your name and credentials will now be published in the Yellow Pages for PHP Professionals. Download the ZCE Logo and add it to your resume and link it to your ZCE Authentication Page from your Website.

Echo Vs Print

...echo is faster 6 times out of 7*.

Tested on manyl servers with different configurations.

So Spend some time on chaning echo to print

Want to uplaod large files and the page is timing out ?

Here is what you do !



where x is your needed time out !

Yes its that simple

This code was working eralier - Check Ini

How many times have we heard that before ! Not only does it make you look like a fool , it also happens so precisely at the time of a Demo.

Yes ! Crap happens !

I was running Drupal the other day and suddenly the code stopped working . I had switched to Wampserver! A quick look at the PHP.INI told me that

short_open_tag = Off

was the problem

the ini files describes it thus

" NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.

that is the code in does not work any more if its short_open_tag is off

So what do we do ?

short_open_tag = On

and save the ini file

now restart the server


use instead as a coding standard . It could save you a lot of trouble.

P. S : this is on PHP 4.x

J2EE V 5 - new relase by Sun JCP approves

Sun Microsystems, Inc., ... today announced that the Java Platform, Enterprise Edition (Java EE) 5 specification has been approved by the Java Community Process (JCP) Java EE/SE Executive Committee in a unanimous vote

Read This
Time to renew your certification

Java Vs PHP

Hi ,
Agreed Both are great technologies ! Just wanted to ask which is better and why ?

Remeber the Precomplied C code is available (as library - Should it not be way faster than Java) . PHP compiles (Encodes) and runs even on IBM servers and Yahoo chose php ! I love my java anyway. Please do let me know what you think.