Monthly archive for January 2010

WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?

January 10, 2010 | Filed Under PHP | Comments Off

There are three type of errors are present in PHP

1-Notices
2-Warnings
3-Fatal errors

Notices:
These are trivial, non-critical errors. that does not terminate script .
Condition:
1- Accessing a variable that not define.

Warnings:
These are more serious errors
Condition:
1-attempting to include() a file which does not exist.

Fatal errors:
These are critical errors that terminate script and stop
Condition:
1-instantiating an object of a non-existent class
2- Calling a  non-existent function
3-Missing semicolon
4-missing braces
5- Destroyed DOM

Article written by admin

Differences between DROP a table and TRUNCATE a table?

January 10, 2010 | Filed Under PHP | Comments Off

DROP: This will delete the table structure and its data.

syntax-DROP TABLE table_name

TRUNCATE: This will delete the table  data but not its structure.
syntax-TRUNCATE TABLE table_name

Article written by admin

What is difference between echo $a or echo {$a} ?

January 10, 2010 | Filed Under PHP | Comments Off

Best way to understand the problem is example.

<?php

$a=’Hello’;

Echo “$aworld” // blank because it treat as variable

Echo “{$a}world” // Helloworld

?>

Article written by admin

What is the default table in MYSQL? which type of table is generatedby default.

January 10, 2010 | Filed Under MySQL | Comments Off

MyISAM is the default storage engine.

Article written by admin

How many number of tables are present in MYSQL Data base?

January 10, 2010 | Filed Under MySQL, PHP | Comments Off

Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM

Article written by admin

How can I execute a PHP script using command line?

January 10, 2010 | Filed Under PHP | Comments Off

Just run the PHP CLI (Command Line Interface) program and provide the PHP script file  name as the command line argument. For example, “php  myScript.php”, assuming “php” is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

Article written by admin

What is difference between Persistent Cookie and Temporary cookies?

January 10, 2010 | Filed Under PHP | 2 Comments

Temporary cookies :

By Default Temporary cookie is active which is store in browser memory, live until browser  is closed.

Persistent Cookie: persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer.

Which is live for a time period defines by programmer in the script.

Example:

<?php

$value = ‘value’;
setcookie("testcookie", $value, time()+3600); /* expire in 1 hour */

// Where 3600 count in 60*60*1 [second*minute*hour]

?>

Article written by admin

Days between two given dates using PHP?

January 10, 2010 | Filed Under PHP | Comments Off

$date1 = date(‘Y-m-d’); // yyyy-mm-dd  format
$date2 = ’2006-07-01′;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo “Number of days since ’2006-07-01′: $days”;

Where strtotime

int strtotime ( string $time [, int $now] )

The function expects to be given  a string containing a US English date format and will try to parse that format into a UNIX timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if now is not supplied.

Article written by admin

How can we repair a MySQL table?

January 10, 2010 | Filed Under JQuery, PHP | Comments Off

There are three syntax  to repair MySQL table.

REPAIR TABLE table_name
REPAIR TABLE table_name QUICK
REPAIR TABLE table_name EXTENDED

If QUICK is given, MySQL will repair index tree.
If EXTENDED is given, it will create index row by row.

Article written by admin

what is LEFT JOIN and RIGHT JOIN, INNER JOIN and OUTER JOIN in mysql?

January 10, 2010 | Filed Under MySQL, PHP | Comments Off

The best way to learn about JOINS is the example. So below is the example to demonstrate JOINS
Suppose that there are two tables
1- Person
2-Information
Person table has definition and data like  that
Person:

Number(Primary key) name phone
1 Mr Sana 0120 234564
2 Mr Urooj 0120 234567
3 Mr Imran 0120 245678

Information:

border=”1″ width=”400″ cellspacing=”0″ cellpadding=”10″>

Entry_id Number Address
1 1 ChandPura, Bahraich UP (INDIA)
2 3 Dadi hat, Bahraich UP (INDIA)
3 3 Qazi pura, Bahraich UP (INDIA)
4 3 New Ashok Nagar, Delhi UP (INDIA)
5 4 Faizadab UP (INDIA)

mysql> select * from person;

out put:

Number(Primary key) name phone
1 Mr Sana 0120 234564
2 Mr Urooj 0120 234567
3 Mr Imran 0120 245678

3 rows in set (0.00 sec)

mysql> select * from information;

Entry_id Number Address
1 1 Chand Pura, Bahraich UP (INDIA)
2 3 Dadi hat, Bahraich UP (INDIA)
3 3 Qazi pura, Bahraich UP (INDIA)
4 3 New Ashok Nagar, Delhi UP (INDIA)
5 4 Faizadab UP (INDIA)

5 rows in set (0.00 sec)

Regular Join:

If apply a regular JOIN (with out use of these keywords INNER, OUTER, LEFT or RIGHT), then I get all records that match in the appropriate way in the two tables, and records in both incoming tables that do not match are not reported:

mysql> select name, phone, address

from person join information

on person.number = information.number;

OR

mysql> select name, phone, address

from person,information where

person.number = information.number;

Output:

name Phone Address
Mr Sana 0120 234564 Chand Pura, Bahraich UP (INDIA)
Mr Imran 0120 245678 Dadi hat, Bahraich UP (INDIA)
Mr Imran 0120 245678 Qazi pura, Bahraich UP (INDIA)
Mr Imran 0120 245678 New Ashok Nagar, Delhi UP (INDIA)

4 rows in set (0.01 sec)

LEFT JOIN:
If I apply left joint with using keyword LEFT JOIN

mysql> select name, phone, address
from person left join information on person.number = information.number;

Output:

name phone address
Mr Sana 0120 234564 Chand Pura, Bahraich UP (INDIA)
Mr Urooj 0120 234567 NULL
Mr Imran 0120 245678 Dadi hat, Bahraich UP (INDIA)
Mr Imran 0120 245678 Qazi pura, Bahraich UP (INDIA)
Mr Imran 0120 245678 New Ashok Nagar, Delhi UP

5 rows in set (0.00 sec)

RIGHT JOIN:
If I apply right joint with using keyword RIGHT JOIN

mysql> select name, phone, address
from person right join information on person.number = information.number;

name phone address
Mr Sana 0120 234564 Chand Pura, Bahraich UP (INDIA)
Mr Imran 0120 245678 Dadi hat, Bahraich UP (INDIA)
Mr Imran 0120 245678 Qazi pura, Bahraich UP (INDIA)
Mr Imran 0120 245678 New Ashok Nagar, Delhi UP
NULL NULL Faizadab UP (INDIA)

5 rows in set (0.00 sec)

OUTER JOIN: Outer join does not support RDBMS.

Article written by admin

What is .htaccess in apache?

January 5, 2010 | Filed Under .htaccess | Comments Off

The .htaccess is Apache configuration file.which is used to control many feature on Apache webserver.
Features are follows

  • password protect directories
  • enable server side includes
  • block users by IP address among other things
  • Create  meaning full URL
  • Change in php.ini settings
  • Forbidding Files
  • Checking access rights
  • show different pages depending on the IP address:
  • process Apache errors (403,404,405)

and many more.

The file name is exactly “dot” htaccess. It must be in the UNIX format (ASCII mode).

Article written by admin

How to enable URL file-access in the server configuration or Godaddy server

January 5, 2010 | Filed Under Others | 5 Comments

If you are getting Warning Messages like this one

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/xxxxxxxxxxxxxxxxxxxxxxxxxx/filecall.php on line 5

Where xxxxxxxxxxxxxxxxxxxxxxxxxx < your server path.

It ‘s means that your server configuration is blocking external file access( include () function in many cases).

To solve this issue you need to set allow_url_fopen= ON and allow_url_include =ON in PHP configuration (php.ini).

If you have not dedicated server, You need to ask for your service provider to set allow_url_fopen= ON, allow_url_include =ON

If you want enable URL file-access setting=on via .htacess
then you need to write php_value allow_url_fopen 1 in .htacess file.
If you want to enable URL file-access via PHP.
Then you need to write <?php
ini_set(‘allow_url_fopen’,'ON’) ; // ON or 1 both are same
ini_set(‘allow_url_fopen’,'ON’) ;
?>

I suggest a solution simple use file_get_contents()instead of include() function.
In this case you don’t need to enable URL file-accessin the server configuration.

Basically Godaddy server doesn’t support include() function due to disable allow_url_fopen.

Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker