Q. What are magic functions or methods in php?
The function names __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state() and __clone() are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them.
__sleep() and __wakeup()
serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.
Note:
It is not possible for __sleep() to return names of private properties in parent classes. Doing this will result in an E_NOTICE level error. Instead you may use the Serializable interface.
The intended use of __sleep() is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which do not need to be saved completely.
Conversely, unserialize() checks for the presence of a function with the magic name __wakeup(). If present, this function can reconstruct any resources that the object may have.
The intended use of __wakeup() is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
Differentiate the LIKE and REGEXP operators?
SELECT * FROM pet WHERE name REGEXP “^b”;
SELECT * FROM pet WHERE name LIKE “%b”;
What are the String types are available for a column?
The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET.
An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.
An enumeration value must be a quoted string literal; it may not be an expression, even one that evaluates to a string value. For example, you can create a table with an ENUM column like this:
CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
What is the REGEXP?
A REGEXP pattern match succeed if the pattern matches anywhere in the value being tested.
What is the difference between CHAR AND VARCHAR?
The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved.
The length of a CHAR column is fixed to the length that you declare when you create the table.
The length can be any value between 1 and 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed.
How quoting and escaping work in SELECT QUERY?
SELECT ‘hello’, ‘hello’,‘hello’, ‘hel‘‘lo’, ‘\‘hello’.
What is the difference between BLOB AND TEXT?
A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB differ only in the maximum length of the values they can hold.
The four TEXT types TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT correspond to the four BLOB types and have the same maximum lengths and storage requirements. The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive fashion for BLOB values and case-insensitive fashion for TEXT values. In other words, a TEXT is a case-insensitive BLOB.
How we get Sum of column?
mysql> SELECT * FROM tablename;
How do you get current user in mysql?
SELECT USER();
How would you change a table to InnoDB?
ALTER TABLE name_file ENGINE innodb;
How do you concatenate strings in MySQL?
CONCAT (string1, string2, string3)
what is difference between primary key and candidate key?
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a primary one and that key is used for any foreign key references.
How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
How do you get the current date in Mysql?
SELECT CURRENT_DATE();
What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): – returns a result row as a associated array, regular array from database.
mysql_fetch_object: – returns a result row as object from database.
You wrote a search engine that should retrieve 10 results at a time, but at the same time you’d like to know how many rows there’re total. How do you display that to the user?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?
It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
How do you display the list of database in mysql?
SHOW DATABASES;
How do you display the structure of the table?
DESCRIBE table_name;
How do you find out which auto increment was assigned on the last insert?
SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name.
What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
How many drivers in Mysql?
There are eleven drivers in MYSQL .Six of them from MySQL AB and five by MYSQL Communities.They are
PHP Driver
ODBC Driver
JDBC Driver
ado.net5.mxj
CAPI1PHP DRIVER
PERL DRIVER
PYTHON DRIVER
RUBY DRIVER
C WRAPPER
How do you run batch mode in mysql?
mysql < batch-file >;
mysql < batch-file > mysql.out
What Storage Engines do you use in MySQL?
Storage engines used to be called table types.
Data in MySQL is stored in files (or memory) using a variety of different techniques. Each of these techniques employs different storage mechanisms, indexing facilities, locking levels and ultimately provides a range of different functions and capabilities. By choosing a different technique you can gain additional speed or functionality benefits that will improve the overall functionality of your application.
Where MyISAM table is stored?
Each MyISAM table is stored on disk in three files.
The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension
Define Primary key?
MYSQL allows only one primary key. A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself.A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.
If the value in the column is repeatable, how do you find out the unique values?
SELECT DISTINCT user_firstname FROM users;
Explain the difference between FLOAT, DOUBLE and REAL?
FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
How do you get the current version of mysql?
SELECT VERSION();
Is Mysql query has LETTERCASE?
No.
Ex :
SELECT VERSION(), CURRENT_DATE;
select version(), current_date;
SeLeCt vErSiOn(), current_DATE;
What is the LIKE?
A LIKE pattern match, which succeeds only if the pattern matches the entire value.
What are ENUMs used for in MySQL?
You can limit the possible values that go into the table.
CREATE TABLE months (month ENUM ’January’, ’February’, ’March’,); INSERT months VALUES (’April’).
What are the advantages of Mysql comparing with oracle?
MySql is Open source, which can be available any time. Provides Gui with Command Prompt. Supports the administration using MySQL Admin,MySQL Query Browser.Oracle is best database ever in Software development.
What is the difference between CHAR_LENGTH and LENGTH?
The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they’re not the same for Unicode and other encodings.
How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
What Is a Session?
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.
There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.
Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
What is meant by PEAR in php?
Answer1:
PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install packages
Answer2:
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.
How can we know the number of days between two given dates using PHP?
Simple arithmetic:
$date1 = date(’Y-m-d’);
$date2 = ‘2006-07-01′;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo Number of days since ‘2006-07-01′: $days;
How can we repair a MySQL table?
The syntex for repairing a mysql table is:
REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED
This command will repair the table specified.
If QUICK is given, MySQL will do a repair of only the index tree.
If EXTENDED is given, it will create index row by row.
What is the difference between $message and $$message?
Anwser 1:
$message is a simple variable whereas $$message is a reference variable. Example:
$user = ‘bob’
is equivalent to
$holder = ‘user’;
$$holder = ‘bob’;
Anwser 2:
They are both variables. But $message is a variable with a fixed name. $$message is a variable who’s name is stored in $message. For example, if $message contains var, $$message is the same as $var.
What Is a Persistent Cookie?
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
What does a special set of tags do in PHP?
What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
How do you define a constant?
Via define() directive, like define (MYCONSTANT, 100);
What are the differences between require and include, include_once?
Anwser 1:
require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:
All three are used to an include file into the current page.
If the file is not present, require(), calls a fatal error, while in include() does not.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
What is meant by urlencode and urldecode?
Anwser 1:
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(10.00%) will return 10%2E00%25?. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Anwser 2:
string urlencode(str) Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:
Alphanumeric characters are maintained as is.
Space characters are converted to + characters.
Other non-alphanumeric characters are converted % followed by two hex digits representing the converted character.
string urldecode(str) Returns the original string of the input URL encoded string.
For example:
$discount =10.00%;
$url = http://domain.com/submit.php?disc=.urlencode($discount);
echo $url;
You will get http://domain.com/submit.php?disc=10%2E00%25?.
How To Get the Uploaded File Information in the Receiving Script?
Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] The Original file name on the browser system.
$_FILES[$fieldName]['type'] The file type determined by the browser.
$_FILES[$fieldName]['size'] The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] The error code associated with this file upload.
The $fieldName is the name used in the <INPUT,>.
What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array
How can I execute a PHP script using command line?
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.
How to get size & type of uploaded image?
list($width, $height, $type) = getimagesize($_FILES['photo_file']['tmp_name']);
How can we submit a form without a submit button?
The main idea behind this is to use Java script submit( function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit( method to onclick, onchange events of different inputs and perform the form submission. you
can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites.
In how many ways we can retrieve the data in the result set of MySQL using PHP?
You can do it by Ways
. mysql_fetch_row.
. mysql_fetch_array
. mysql_fetch_object
. mysql_fetch_assoc
What is the difference between mysql_fetch_object and mysql_fetch_array?
mysql_fetch_object( is similar tomysql_fetch_array(, with one difference – an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names.
What is the difference between $message and $$message?
It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan
with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?
preg_match(”/^http:\/\/.+@(.+$/”,’http://info@abc.com’,$found;
echo $found[];
How can we create a database using PHP and MySQL?
We can create MySQL database with the use of
mysql_create_db(“Database Name”
What are the differences between require and include, include_once and require_once?
The include( statement includes and evaluates the specified file.The documentation below also applies to require(. The two constructs are identical in every way except how they handlefailure. include( produces a Warning while require( results in a Fatal Error. In other words, use require( if you want a missingfile to halt processing of the page.
include( does not behave this way, the script will continue regardless.
The include_once( statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include( statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once( should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once( should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
Can we use include (”abc.PHP” two times in a PHP page “makeit.PHP”?
Yes we can use include( more than one time in any page though it is not a very good practice.
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(,ename varchar(0 ?
Total types of tables we can create
. MyISAM
. Heap
. Merge
. INNO DB
. ISAM
MyISAM is the default storage engine as of MySQL . and as a result if we do not specify the table name explicitly it will be assigned to the default engine.
0
How can we encrypt the username and password using PHP?
0
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption
AES_ENCRYT( AES_DECRYPT(
ENCODE( DECODE(
DES_ENCRYPT( DES_DECRYPT(
ENCRYPT( Not available
MD( Not available
OLD_PASSWORD( Not available
PASSWORD( Not available
SHA( or SHA( Not available
Not available UNCOMPRESSED_LENGTH(
How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
How do you start and stop MySQL on Windows?
net start MySQL, net stop MySQL
How do you start MySQL on Linux?
/etc/init.d/mysql start
Explain the difference between mysql and mysql interfaces in PHP?
mysqli is the object-oriented version of mysql library functions.
What’s the default port for MySQL Server?
0
What does tee command do in MySQL?
tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command note.
Can you save your connection settings to a conf file?
Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 00, so that it’s not readable by others.
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
Use mysqldump to create a copy of the database?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
Have you ever used MySQL Administrator and MySQL Query Browser?
Describe the tasks you accomplished with these tools.
0 What are some good ideas regarding user security in MySQL?
There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet. There are as few users as possible (in the ideal case only root who have unrestricted access.
Explain the difference between MyISAM Static and MyISAM Dynamic. ?
In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.
What does myisamchk do?
It compressed the MyISAM tables, which reduces their disk usage.
Explain advantages of InnoDB over MyISAM?
Row-level locking, transactions, foreign key constraints and crash recovery.
Explain advantages of MyISAM over InnoDB?
Much more conservative approach to disk space management – each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy ,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*s execute slower than in MyISAM due to tablespace complexity.
What are HEAP tables in MySQL?
HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
How do you control the max size of a HEAP table?
MySQL config variable max_heap_table_size.
What are CSV tables?
Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
Explain federated tables. ?
Introduced in MySQL .0, federated tables allow access to the tables located on other databases on other servers.
What is SERIAL data type in MySQL?
BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
0 What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table?
It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
Explain the difference between BOOL, TINYINT and BIT. ?
Prior to MySQL .0.: those are all synonyms. After MySQL .0.: BIT data type can store bytes of data and should be used for binary data.
Explain the difference between FLOAT, DOUBLE and REAL. ?
FLOATs store floating point numbers with place accuracy and take up bytes. DOUBLEs store floating point numbers with place accuracy and take up bytes. REAL is a synonym of FLOAT for now.
If you specify the data type as DECIMAL (,, what’s the range of values that can go in this table?
. to -.. Note that with the negative number the minus sign is considered one of the digits.
What happens if a table has one column defined as TIMESTAMP?
That field gets the current timestamp whenever the row gets altered.
But what if you really want to store the timestamp data, such as the publication date of the article?
Create two columns of type TIMESTAMP and use the second one for your real data.
Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ?
The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.
What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
Explain TIMESTAMP DEFAULT ‘00:0:0 ::? ON UPDATE CURRENT_TIMESTAMP. ?
A default value is used on initialization, a current timestamp is inserted on update of the row.
If I created a column with data type VARCHAR(, what would I expect to see in MySQL table?
CHAR(, since MySQL automatically adjusted the data type.
General Information About MySQL
MySQL is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language database server.
0 MySQL is free software.
It is licensed with the GNU GENERAL PUBLIC LICENSE http://www.gnu.org/.
What Is MySQL
MySQL, the most popular Open Source SQL database, is provided by MySQL AB. MySQL AB is a commercial company that builds is business providing services around the MySQL database. See section . What Is MySQL AB.
MySQL is a database management system.
A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL. Since computers are very good at handling large amounts of data, database management plays a central role in computing, as stand-alone utilities, or as parts of other applications.
MySQL is a relational database management system.
A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The tables are linked by defined relations making it possible to combine data from several tables on request. The SQL part of MySQL stands for “Structured Query Language” – the most common standardized language used to access databases.
MySQL is Open Source Software.
Open source means that it is possible for anyone to use and modify. Anybody can download MySQL from the Internet and use it without paying anything. Anybody so inclined can study the source code and change it to fit their needs. MySQL uses the GPL (GNU General Public License http://www.gnu.org, to define what you may and may not do with the software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL into a commercial application you can buy a commercially licensed version from us.
Why use MySQL?
MySQL is very fast, reliable, and easy to use. If that is what you are looking for, you should give it a try. MySQL also has a very practical set of features developed in very close cooperation with our users. You can find a performance comparison of MySQL to some other database managers on our benchmark page. See section . Using Your Own Benchmarks. MySQL was originally developed to handle very large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Though under constant development, MySQL today offers a rich and very useful set of functions. The connectivity, speed, and security make MySQL highly suited for accessing databases on the Internet.
The technical features of MySQL
For advanced technical information, see section MySQL Language Reference. MySQL is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and a programming interface. We also provide MySQL as a multi-threaded library which you can link into your application to get a smaller, faster, easier to manage product. MySQL has a lot of contributed software available.
It is very likely that you will find that your favorite application/language already supports MySQL. The official way to pronounce MySQL is “My Ess Que Ell” (not MY-SEQUEL. But we try to avoid correcting people who say MY-SEQUEL.
Session and cookie
What is the difference between session and cookie ?
flash
How can we call flash banner in dreamweaver..
php swapp two name surmane
why we use @?
Give the ans.
what is the difference between sql and mysql
SQL means “structured query language” which is the syntax of commands you send to database. MYSQL is the database program which accepts the those commands and gives out the data.
Please Help
I have created a php site in dreamweaver but i have not stored the files in www directory of wamp. now i want to move the files to www directory without losing the links that i’ve created… how is it possible??
How i get DPI of uploaded image
Can any one tell me how can i get DPI of uploaded image. Thanx
zend framework
Hi evryone, how do i call stored procedure from zend framework using oracle database and how to echo the data. muzeeb
what is the difference between echo and print in php?
When outputting something with PHP, we use print or echo functions. what exactly is the difference between those functions?
PHP – Drupal Joomla Developer required 2 – 3 Years Experienced – MNC Bangalore
Please send your resumes for the Drupal Joomla Opening – Reputed Company – Bangalore Requirement: 2 – 3 years experience in Joomla / Drupal & PHP Contact on bshibin@gmail.com
difference between superkey candidate and primary keys
Super key is the set of attributes in a table that can uniquely identifies a database tuple(row or record). Candidate key is the minimal set of super key that can uniquely identifies a database record. Primary key is one of the candidate keys. you can select any candidate k
Custom redirect in drupal after the node is created?
Please use the following snippet for the custom redirect. function module_form_alter(&$form,$form_state,$form_id){ if (isset($form['#node']) && $form['#node']->type .’_node_form’ == $form_id) { $form['buttons']['submit']['#submit'][] = ‘module_redirect_handler’; }
How to enable HTML option for Drupal menus?
/* *Enabling HTML option for Drupal menus */ function theme_menu_item_link($link) { $link['localized_options']['html'] = true; return l($link['title'], $link['href'], $link['localized_options']); }
Why “pageTracker is not defined” error when using pageTracker._trackPageLoadTime();?
Please try use _gaq.push([‘_trackPageLoadTime’]); instead. It will work !!!
Why mousewheel.js/Jscrollpane.js ( scrolloing using mouse wheel ) not working in Firefox?
It might be because of Jscrollpane.js issue. The Quick solution to solve this issue is to edit the Jscroolpane.js. Go to particular line number ( Mostly:341 ) and change to var dragOffset = $drag.offset(false); currentOffset = { top: dragOffset.top, left:dragOffse
How to create admin settings form in Drupal?
How to extract content between anchor tags using Javascript?
In Jquery we can follow the following to iterate the contents.
Why “#” needs to be encoded in the URLs?
If you are using any “#” in the URLs it should be in the encoded form. Its because of this is used in URLs to mention where the fragment indicators ( eg:bookmarks or anchors in HTML ) begins in URLs.
Checking whether your MySQL server supports partitioning?
Before implementing any user defined partitioning in MySQL we need to make sure whether your mysql server supports partitioning. Finding out the same in your server will be simple. Type SHOW VARIABLES LIKE ‘%partition%’; on the command prompt as shown below. mysql> SHOW
why $_POST is better even though view source of the form gives the details
Plz some one give me the answer
Advantages of MySQL 5.1 compared to MySQL 5
Please find the following features that has been added to the MySQL version 5.1. 1. Partitioning 2. Row Based Replication 3. Plugin API 4. Server log table 5. Upgrade program 6. MySQL Cluster 7. Backup of tablespaces 8. Improvements to INFORMATION_SCHEMA 9. XML functio
disable the drupal cache for a page and for a module in drupal site
There is a contributed module to exclude drupal cache for particular pages in your drupal site. you can find the module in http://drupal.org/project/cacheexclude . for excluding drupal cache for a particular module write the below mentioned code in ur modulename_init() hook
How to send mail using MSSQL Express edition
I need to know the use of MS Sql express edition for sending mails.
Caching – How caching is implemented in Drupal?
For improving the the performance of the Drupal site we can use the caching mechanism. In caching rather than extracting the same data again and again every time, it stores the frequentltay accessed and static data in a convenient place and format. Drawback of caching is that,
Recommend commonly used modules for Drupal?
When an interviewer is asking these question please make sure before recommending any module 1. Whats the use of that module? 2. How well it is supported? 3. Any Vulnerabilities with the module?
Drupal – Overriding style sheets from modules and drupal core
Option 1 To override a core or contributed module style sheet, it must be specified in your theme’s .info file. For example, system-menus.css is located at “modules/system/system-menus.css”. If you place a file with the same name in your theme’s folder and add the following ent
Drupal – Overriding Drupal Core Javascript Files?
cognizant php interview questions?
Do any one have Cognizant/Capgemini interview questions for php/Drupal?
Openings with TCS BPO
Start Career With TCS Walk-in for graduates from the Batch 2010 and 2011 BA/BBA/BBM/B Com/BSc/MSc ( Statistics/Maths ) / M.Com On Saturday 16th April 2011 At TCS, Think Campus,#42, Electronic City, Phase II, Bangalore 100
Why the drupal blocks are disappearing after submitting the form?
Why the drupal blocks are disappearing after submitting the form?
Why the drupal blocks are disappearing after submitting the form?
Do any one have any idea why the blocks are disappearing?
How to create a new region in Drupal 6?
Please follow the following steps to create new regions for Drupal 6 ADD the following region information to you theme.info file: regions[left] = Left sidebar regions[right] = Right sidebar regions[content] = Content regions[header] = Header regions[footer] = Foote
how i can show msg for user when someone try to login
Hello everybody ..! :D i’m working on a E-Bank project , and i need script to show msg for the user when some try to login in at the same username and password at the same time ? Best Regards ..!
Altering form in drupal?
Hook_form_alter Drupal hook function or hook_form_alter(&$form, &$form_state, $form_id) Perform alterations before a form is rendered. One popular use of this hook is to add form elements to the node form. When altering a node form, the node object ca
What is AJAX?
Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire w
What is the difference between constructors in PHP4 & PHP5?
Constructors – PHP4 Constructors are functions in a class that are automatically called when you create a new instance of a class with new. A function becomes a constructor, when it has the same name as the class. If a class has no constructor, the constructor of the base cla
What is meant by Exceptional Handling?
Exceptions PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, try and caught within PHP. A Try block must include at least one catch block. Multiple catch blocks can be used to catch different classtypes; execution will co
What is meant by Virtual hosting?
Virtual hosting HTTP includes the concept of virtual hosting, where a single HTTP server can represent multiple hosts at the same IP address. A DNS server can allocate several different host names to the same IP address. When an HTTP client ma
What is meant by Session Clustering?
The Session Manager session support allows multiple server instances to share a common pool of sessions, known as a session cluster Session clustering setting up methods :
How does Database handle Sessions?
As you should be aware the HTTP protocol, as used for serving web pages, is completely stateless. This means that after the server has received a request, processed it and sent a response, the process which dealt with that request dies. Anything that
What is the difference between include and include_once?
Include() The include() statement includes and evaluates the specified file. This also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error.
Tell me some thing about mod_rewrite and url rewriting?
Mod_rewrite *************
What are static methods?
Static Keyword Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can). The static declar
What is Phishing?
In computing, phishing is a form of criminal activity using social engineering techniques. It is characterized by attempts to fraudulently acquire sensitive information, such as passwords and credit card details, by masquerading as a trustworthy person or business in an ap
Do you know about Cross site Scripting ?
Cross-site scripting (XSS) is a security exploit in which the attacker inserts malicious coding into an link that appears to be from a trustworthy
What is session hijacking?
Session hijacking, also known as TCP session hijacking, is a method of taking over a Web user session by surreptitiously obtaining the session ID and masquerading as the authorized user. Once the user’s session ID has been accessed (through session prediction), the attacker
Authentication – General Definition
Authentication is the process of determining whether someone or something is, in fact, who or what it is declared to be. In private and public computer networks (including the Internet), authentication is commonly done through the use of logon passwords. Knowledge of the p
What is smarty?
Smarty is a template engine written in PHP. Typically, these templates will include variables —such as {$variable}— and a range of logical and loop operators to allow adaptability within of the template.
What is Model-view-controller (MVC)?
Model-view-controller (MVC) is a design pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (model) and user interface (view) concerns, so that changes to the user interface do not
What is the difference between mysql_fetch_object and mysql_fetch_array?
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. mysql_fetch_object() example
How can we submit a form without a submit button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form
What is the difference between GET and POST methods in form submitting? Give the cases where we can use GET and POST methods?
The main difference between GET and POST is how the form data is passing. Both are used for passing form field values. All the values which is submitted by the GET method will be appended to the URL. Where as POST method send the data with out appending the URL(
What is the difference between strstr() and stristr()?
Strstr — Find first occurrence of a string strstr() example stristr — Case-insensitive strstr() stristr() example
What is meant by PEAR in php?
PEAR PHP Extension and Application Repository PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wiz
How can we know the count/number of elements of an array?
A) sizeof($urarray) This function is an alias of count() b) count($urarray)
What is the difference between the functions unlink() and unset()?
Unlink is a function for file system handling. It will simply delete the file in context unset will set UNSET the variable
What is meant by urlencode and urldecode?
String urlencode(str) where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world string urldocode(str)
How can we repair a MySQL table?
The syntex for repairing a mysql table is REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended] This command will repair the table specified if the quick is given the mysql will do a repair of only the index tree if the extended is given it will create in
What is the maximum length for database, table & column names?
database- 64 table -64 columns-64 alias-255
What are the commands to find the structure of a MySQL table other than EXPLAIN command?
Describe table_name
What is the difference between char and varchar data types?
Set char to occupy n bytes and it will take n bytes even if u r storing avalue of n-m bytes Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes eg. name char(10) will waste 5 bytes if we store ‘testname&rsqu
What is the functionality of md5 function in PHP?
Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number.
What is the difference between GROUP BY and ORDER BY in MySQL?
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
What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transm
Is it possible to pass data from JavaScript to PHP?
A. Yes, but not without sending another HTTP request. B. Yes, because PHP executes before JavaScript. C. No, because JavaScript is ser
what is session_start() ?
When a user first encounters a page in your application that call ssession start(),a sessionis created for the user.PHP generates a random session identifier to identify the user,and then it sends a set-Cookieheader to the client.By default,the name of this cookie is PHPSE
How do you convert an old fashioned 10 digit ISBN to a new 13 digit ISBN using php ?
function isbn10_to_13($isbnold){ if (strlen($isbnold) != 10){ // Make sure we have a 10 digit string to start return ‘Invalid ISBN-10
What’s foreign data in php?
* Anything from a form * Anything from $_GET, $_POST, $_REQUEST * Cookies ($_COOKIES) * Web services data * Files
What is str_split function in php?
According to PHP official manual It is used to converts a string to an array. If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character
How can we encrypt and decrypt a data present in a MySQL table using MySQL?
There are two methods AES_ENCRYPT () and AES_DECRYPT ()
How can we find the number of rows in a table using MySQL?
SELECT COUNT(*) FROM tb_nme;
Where MyISAM table is stored ?
Each MyISAM table is stored on disk in three files. The ‘.frm&r
How many types of buffers does use MySQL?
Global buffers and per-connection buffers
what is the use of –i-am-a-dummy flag in MySql?
It Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present.
Is MySQL better than MSSQL ?
Mysql is the most popular open source database server right now. It is used by large enteprise level companies and small, single websites. Is mysql actually better? ——————————— Mysql 5.
What is the Use of “WITH ROLLUP” in Mysql?
http://www.w3answers.com
How to determine the number of rows in the full result set and also restrict the number of rows that a query returns….
How to determine the number of rows in the full result set and also restrict the number of rows that a query returns,without running a second query ? Most of the developers using 2 queries to find total numbe
What is the maximum length of a table name, a database name, or a field name in MySQL?
Database name: 64 characters Table name: 64 characters Column name: 64 characters
How many values can the SET function of MySQL take?
MySQL SET function can take zero or more values, but at the maximum it can take 64 values.
How many ways we can we find the current date using MySQL?
SELECT CURTIME(); SELECT CURDATE(); SELECT CURRENT_TIME();
What is the difference between CHAR and VARCHAR data types?
Ans: CHAR is a fixed length data type.
How can we know the number of days between two given dates using MySQL?
Using DATEDIFF() SELECT DATEDIFF(NOW(),’2007-07-15′);
what is database testing and what we test in database testing?
Database testing basically include the following. 1)Data validity testing. 2)Data Integritity testing 3)Performance related to data base. 4)Testing of Procedure,triggers and functions. for doing data validity testing you should be good in SQL q
How can we take a backup of mysql table and restore it?
These are the simplest method to backup and restore the MySQl table For taking the bakup of all the databases mysqldump –user {user
Is it possible to set a time expire page in PHP.?
Yes it is Using header(“Expires: Mon, 26 Jul 2007 05:00:00 GMT&qu
How can we save an image from a remote web server to my web server using PHP?
what is the output of 2^2 in php ?
The answer is 0 (Zero) Important note Everyone expected answer would be 4.But answer is zero.How it happened only in php ? The ^ oper
what is the output of below script?
a. echo ‘line 3′; b. echo ‘line 2′; c. Error d. None of the above Ans: b (Answer is line2)
What is the output here?
a. hello sunil b. Parse error c. hello $x d. syntax error ANS: c published by http://www.w3answers.com
Tutoring Online – Cookies and Sessions
Hi my dear friends. Everybody knows what is cookie and session. But let me tell a truth, most of the beginners don’t know properly what is happening in cookies and sessions and what is the real use .I have taken so many Interviews but none of them given a good
What is PHP?
PHP: Hypertext Preprocessor, an open source, server-side, HTML embedded scripting language used to create dynamic Web pages.
What can PHP do?
Anything. PHP is mainly focused on server-side scripting, so you can do anything any other CGI program can do, such as coll
Your first PHP script – “Hello World”
PHP Test
How we can pass data from PHP to ASP,ASP.net?
PHP to ASP Let’s first look at how you can pass data from PHP to ASP using WDDX. You create a WDDX packet by first serializi
How can you block certain IP Addresses from accessing your site?
What Storage Engines do you use in MySQL?
MySQL Engines
What is Apache?
The most widely available HTTP server on the Internet. It supports the PERL and PHP languages.
Installing PHP on your Computer?
You can download apache2triad from
How to convert ASP Arrays to PHP and viceversa ?
ASP Arrays to PHP WDDX also allows more-complicated data structures to be passed between applications. Here we will pass an array from an ASP WDDX script to a PHP script.
Which of the following represents the proper way to set a session variable?
A. $_SESSION[‘foo’] = ‘bar’; B. session_start(); C. session_set_save_handler (‘myopen’, ‘myclose’, ‘myread’, ‘mywrite’, ‘mydelete’, ‘mygarbage&
PHP Functions for WDDX
PHP has a few other functions that can be useful when you’re working with WDDX:
what output do you get here?
a. home b. Array c. test d. httpd ANS: httpd
Which of the following functions is most efficient for substituting fixed patterns in strings?
A. preg_replace() B. str_replace() C. str_ireplace() D. substr_replace()
Which function in PHP gives us absolute path of a file on the server?
Ans: getcwd() Here I have stored my files under httdocs (using php5,i haven’t checked under php4) so I get the output as C:\apache2triad\htdocs you may get your path information while runnings the above code. :)
what is the output here ?
The output : http://www.w3answers.com and warning as below Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advise
what is the output ?
a. ouch b. echo c. none d. Parse error ANS: a
How can we extract string “w3answers.com” from a string mailto:info@w3answers.com using regular expression of PHP ?
Answer: <?php $w3 = “mailto:info@w3answers.com”; preg_match(‘|.*@([^?]*)|’,$w3,$w3output); echo $w3output[1]; ?>
Why should we use Object oriented concepts in php ?
1. Object oriented PHP code is much more reusable because by its’ very nature, it is modular. 2. Object oriented PHP is easier to update. Again, because PHP code is organised into objects. 3. Object oriented PHP makes team programming much easier
which is faster mysql_unbuffered_query or mysql_query ?
When we do the select queries that retrieve large data sets from MySQL, mysql_unbuffered_query in PHP is likely to give better performance than mysql_query. PHP manual says, it “sends a SQL query query to MySQL, without fetching
How to capture content from the output buffer ? or Give me an example for Output caching in php?
What is the difference between $message and $$message?
$message is a simple variable whereas $$message is a variable’s variable,which means value of the variable. Example: $user = ‘bob’ is equivalent to $message = ‘user’; $$message = ‘bob’;
what is the php solution to dynamic caching ?
PHP offers an extremely simple solution to dynamic caching in the form of output buffering.
what are the most common caching policy approaches ?
1)Time triggered caching (expiry timestamp). 2)Content change triggered caching (sensitive content has changed, so cache must be updated). 3)Manually triggered caching (man
What Are PHP Arrays?
PHP arrays are associative arrays with a little extra machinery thrown in. The associative part means that arrays store element values in association with key values rather than in a strict linear index order. (If y
Are php strings immutable ?
PHP strings can be changed, but the most common practice seems to be to treat strings as immutable.Strings can be changed by treating them as character arrays and assigning directly into them, like this:
What is Memcache?
Memcache is a technology which caches objects in memory where your web application can get to them really fast. It is used by sites such as Digg.com, Facebook.com and NowPublic.com and is widely recognized as an essential ingredient in scaling any LAMP
How do I prevent Web browsers caching a page in php?
What is the process that takes place when you upload a file in php?
There are two basic things covered here. The form that will be used to post the file data to and the actual program that does the uploading. Further we will discuss the method that PHP itself suggests for uploading files. Process 1 HTML PART
Will persistent connection work in the CGI version of php ? mysql_connect() vs mysql_pconnect()?
Persistent database connections work only in the module installation of PHP. If you ask for a persistent connection in the CGI version, you will simply get a regular connection.
What are the ‘function problems’ you have met in php?
1)Call to undefined function we_w3answers() PHP is trying to call the function we_w3answers(), which has not been because you misspelled the name of a function (built-in or use
Explain Parse Errors ? what are the most common causes of parse errors ?
The most common category of error arises from mistyped or syntactically incorrect PHP code, which confuses the PHP parsing engine. 1)The missing semicolon If each PHP instruction is not duly finished off with a semicolon, a parse e
List out some session functions in php?
session_save_path — Get and/or set the current session save path session_is_registered — Find out whether a global variable is registered in a session session_unset — Free all session variables session_cache_expire — Ret
What is meant by Persistent Database Connections?
How many ways your web server can utilize PHP to generate web pages?
Mainly there are three ways
How to opening excel files in windows nad linux using php ?
if you’re using PHP on Windows, you can use the inbuilt COM library $excel = ne
what are the ways to check image mime types in php?
There are a few inbuilt options you can use however, for example getimagesize() can return the mimetype, as does some of the new fileinfo functions. The mime type in getimagesize is stored in ‘mime’, and can be accessed as shown below.
Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
$stringOfText = “<p>This is a test</p>”; $expression = “/<
what you should know about cookies before start using in php?
There are a few things you should be aware of: 1. Since cookies are used to record info
what are the database space-saving functions available in php ?
# Use ip2long() and long2ip() to store the IP adresses as Integers instead of storing them as strings, which will reduce the
what are the security tips you should know before developing php/mysql web pages ?
1. Do not trust user input. 2. Validate user input on the server side. 3. Do not use user input directly in your MySQL queries. 4. Don’t put integers in quotes In your MySQL queries. 5. Always escape the output using ph
How to get the contents of a web page using php?
You can achieve this using curl in php see the example below.
what are the advantages of storing sessions in database?
If you store a session in a database you have several advantages:
How many HTTP headers will send to a web page(client side) from server when you use sessions (session_start()) in php ?
There are three HTTP headers included in the response: Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache
php supports following database
A) Solid & oracle b) mysql c) None of the above d) All of the above All of the above
PHP comments will be?
A) // b) /* fgfg */ c) All of the above d) First one ANS: All of the above
What is the output for the following script ?
a) syntax error b) runtime error c) all of the above d) hihihi welcome hihihi ANS: d
what is the output below mentioned?
a) String not matched b) Match found c) All of the above d) None of the above ANS : b (no
what is the output below mentioned ?
a) Error b) APPLE c) Apple d) None of the above ANS : APPLE
what is the output below mentioned?
a) mmer b) mer c) all of the above d) none of the above ANS: none of the above NOTE: if we execute the above code we get the output as ‘m programmer’
what is the output here?
a) false b) true c) error d) declaration error ANS : true
what output do you get here?
Www.w3answers.com w3answers.blogspot.com Ans:Array NOTE: use ‘foreach($r as $v)’ then try to output value ‘echo $v’ or use Print_r($r) so if we make above script as
what is scandir() ?
Www.w3answers.com List files and directories inside the specified path By default files order will be ascending $f = scandir($direct, 1); it will display the files as descending order
What function would you use to redirect the browser to a new page?
1. redir() 2. header() 3. location() 4. redirect() ANS:header()
What function can you use to open a file for reading and writing?
1. fget(); 2. file_open(); 3. fopen(); 4. open_file(); ANS:fopen();
How can you get round the stateless nature of HTTP using PHP?
ANS: using Sessions in PHP
What would the following code print to the browser? Why?
Ans: 10 because,its a call by value.$num is static here. change the above code as
What are the different functions in sorting an array?
Ans:
How can we know the number of elements in an array using php?
Ans:There are two ways: 1) sizeof($myarray) – This function is an alias of count() 2) count($array) – This function returns the number of elements in an array. Note if you just pass a simple variable instead of an array, count() will retur
How can we know the number of elements in an array using php?
Ans: There are two ways: 1) sizeof($myarray) – This function is an alias of count() 2) count($array) – This function returns the number of elements in an array. Note if you just pass a simple variable instead of an array, count() will return 1.
How can we get second of the current time using date function?
What will be the following script output?
A. 2 B. 1 C. Null D. True E. 3 Answer A is correct. Because of operator precedence, the modulus operation is performed first, yielding a result of 2 (the remainder of the division of 5 by 2). Then, the result of this operation is
Which data type will the $a variable have at the end of the following script?
A. (int) 1 B. (string) “1” C. (bool) True D. (float) 1.0 E. (float) 1 Answer B is correct. When a numeric string is assigned to a variable, it remains a string, and it is not converted until needed because of an operation that
What will be the following script output?
A. 2 B. 1 C. 3 D. 0 E. Null Answer B is correct.
what is ajax? when ajax was born?
“AJAX is an acronym for Asynchronous JavaScript and XML. If you think it doesn’t say much, we agree. Simply put, AJAX can be read “empowered JavaScript”, because it essentially offers a technique for client-side JavaScript to make background server calls(such as from PHP,ASP.NET,
What API function provides the connection between the client and server?
ANS:XMLHttpRequest
Should I use an HTTP GET or POST for my AJAX calls?
AJAX requests should use an HTTP GET request when retrieving data where the data will not change for a given request URL. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idem potency recommendations and is highly recommended for a consis
What is MySQL?
MySQL (pronounced “my ess cue el”) is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL a
What Is a Persistent Cookie?
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
What does a special set of tags do in PHP?
What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
How do you define a constant?
Via define() directive, like define (”MYCONSTANT”, 100);
What are the differences between require and include, include_once?
Anwser 1:
require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:
All three are used to an include file into the current page.
If the file is not present, require(), calls a fatal error, while in include() does not.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
What is meant by urlencode and urldecode?
Anwser 1:
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(”10.00%”) will return “10%2E00%25″. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Anwser 2:
string urlencode(str) – Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:
Alphanumeric characters are maintained as is.
Space characters are converted to “+” characters.
Other non-alphanumeric characters are converted “%” followed by two hex digits representing the converted character.
string urldecode(str) – Returns the original string of the input URL encoded string.
For example:
$discount =”10.00%”;
$url = “http://domain.com/submit.php?disc=”.urlencode($discount);
echo $url;
You will get “http://domain.com/submit.php?disc=10%2E00%25″.
How To Get the Uploaded File Information in the Receiving Script?
Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] – The Original file name on the browser system.
$_FILES[$fieldName]['type'] – The file type determined by the browser.
$_FILES[$fieldName]['size'] – The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] – The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] – The error code associated with this file upload.
The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>.
What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array
How can I execute a PHP script using command line?
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.
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.
Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example?
In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like “{$a},000,000 mln dollars”, then you definitely need to use the braces.
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))?
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23. When you fire the above create query MySQL will create a MyISAM table.
How To Create a Table?
If you want to create a table, you can run the CREATE TABLE statement as shown in the following sample script:
<?php
include “mysql_connection.php”;
$sql = “CREATE TABLE fyi_links (”
. ” id INTEGER NOT NULL”
. “, url VARCHAR(80) NOT NULL”
. “, notes VARCHAR(1024)”
. “, counts INTEGER”
. “, time TIMESTAMP DEFAULT sysdate()”
. “)”;
if (mysql_query($sql, $con)) {
print(”Table fyi_links created.\n”);
} else {
print(”Table creation failed.\n”);
}
mysql_close($con);
?>
Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script, you will get something like this:
Table fyi_links created.
How can we encrypt the username and password using PHP?
Answer1
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(”Password”);
Answer2
You can use the MySQL PASSWORD() function to encrypt username and password. For example,
INSERT into user (password, …) VALUES (PASSWORD($password”)), …);
How do you pass a variable by value?
Just like in C++, put an ampersand in front of it, like $a = &$b
WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?
string strstr ( string haystack, string needle ) returns part of haystack string from the first occurrence of needle to the end of haystack. This function is case-sensitive.
stristr() is idential to strstr() except that it is case insensitive.
When are you supposed to use endif to end the conditional statement?
When the original if was followed by : and then the code block without braces.
How can we send mail using JavaScript?
No. There is no way to send emails directly using JavaScript.
But you can use JavaScript to execute a client side email program send the email using the “mailto” code. Here is an example:
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location=”mailto:mailid@domain.com?subject=…”;
return true;
}
What is the functionality of the function strstr and stristr?
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example: strstr(”user@example.com”,”@”) will return “@example.com”.
stristr() is idential to strstr() except that it is case insensitive.
What is the difference between ereg_replace() and eregi_replace()?
eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.
How do I find out the number of parameters passed into function9. ?
func_num_args() function returns the number of parameters passed in.
What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
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,
If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
5, it’s a reference to existing variable.
The function names __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state() and __clone() are magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them.
__sleep() and __wakeup()
serialize() checks if your class has a function with the magic name __sleep(). If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.
Note:
It is not possible for __sleep() to return names of private properties in parent classes. Doing this will result in an E_NOTICE level error. Instead you may use the Serializable interface.
The intended use of __sleep() is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which do not need to be saved completely.
Conversely, unserialize() checks for the presence of a function with the magic name __wakeup(). If present, this function can reconstruct any resources that the object may have.
The intended use of __wakeup() is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
Differentiate the LIKE and REGEXP operators?
SELECT * FROM pet WHERE name REGEXP “^b”;
SELECT * FROM pet WHERE name LIKE “%b”;
What are the String types are available for a column?
The string types are CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET.
An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.
An enumeration value must be a quoted string literal; it may not be an expression, even one that evaluates to a string value. For example, you can create a table with an ENUM column like this:
CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
What is the REGEXP?
A REGEXP pattern match succeed if the pattern matches anywhere in the value being tested.
What is the difference between CHAR AND VARCHAR?
The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved.
The length of a CHAR column is fixed to the length that you declare when you create the table.
The length can be any value between 1 and 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed.
How quoting and escaping work in SELECT QUERY?
SELECT ‘hello’, ‘hello’,‘hello’, ‘hel‘‘lo’, ‘\‘hello’.
What is the difference between BLOB AND TEXT?
A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB differ only in the maximum length of the values they can hold.
The four TEXT types TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT correspond to the four BLOB types and have the same maximum lengths and storage requirements. The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive fashion for BLOB values and case-insensitive fashion for TEXT values. In other words, a TEXT is a case-insensitive BLOB.
How we get Sum of column?
mysql> SELECT * FROM tablename;
How do you get current user in mysql?
SELECT USER();
How would you change a table to InnoDB?
ALTER TABLE name_file ENGINE innodb;
How do you concatenate strings in MySQL?
CONCAT (string1, string2, string3)
what is difference between primary key and candidate key?
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a primary one and that key is used for any foreign key references.
How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
How do you get the current date in Mysql?
SELECT CURRENT_DATE();
What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): – returns a result row as a associated array, regular array from database.
mysql_fetch_object: – returns a result row as object from database.
You wrote a search engine that should retrieve 10 results at a time, but at the same time you’d like to know how many rows there’re total. How do you display that to the user?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?
It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
How do you display the list of database in mysql?
SHOW DATABASES;
How do you display the structure of the table?
DESCRIBE table_name;
How do you find out which auto increment was assigned on the last insert?
SELECT LAST_INSERT_ID() will return the last value assigned by the auto_increment function. Note that you don’t have to specify the table name.
What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
How many drivers in Mysql?
There are eleven drivers in MYSQL .Six of them from MySQL AB and five by MYSQL Communities.They are
PHP Driver
ODBC Driver
JDBC Driver
ado.net5.mxj
CAPI1PHP DRIVER
PERL DRIVER
PYTHON DRIVER
RUBY DRIVER
C WRAPPER
How do you run batch mode in mysql?
mysql < batch-file >;
mysql < batch-file > mysql.out
What Storage Engines do you use in MySQL?
Storage engines used to be called table types.
Data in MySQL is stored in files (or memory) using a variety of different techniques. Each of these techniques employs different storage mechanisms, indexing facilities, locking levels and ultimately provides a range of different functions and capabilities. By choosing a different technique you can gain additional speed or functionality benefits that will improve the overall functionality of your application.
Where MyISAM table is stored?
Each MyISAM table is stored on disk in three files.
The ‘.frm’ file stores the table definition.
The data file has a ‘.MYD’ (MYData) extension.
The index file has a ‘.MYI’ (MYIndex) extension
Define Primary key?
MYSQL allows only one primary key. A primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself.A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.
If the value in the column is repeatable, how do you find out the unique values?
SELECT DISTINCT user_firstname FROM users;
Explain the difference between FLOAT, DOUBLE and REAL?
FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
How do you get the current version of mysql?
SELECT VERSION();
Is Mysql query has LETTERCASE?
No.
Ex :
SELECT VERSION(), CURRENT_DATE;
select version(), current_date;
SeLeCt vErSiOn(), current_DATE;
What is the LIKE?
A LIKE pattern match, which succeeds only if the pattern matches the entire value.
What are ENUMs used for in MySQL?
You can limit the possible values that go into the table.
CREATE TABLE months (month ENUM ’January’, ’February’, ’March’,); INSERT months VALUES (’April’).
What are the advantages of Mysql comparing with oracle?
MySql is Open source, which can be available any time. Provides Gui with Command Prompt. Supports the administration using MySQL Admin,MySQL Query Browser.Oracle is best database ever in Software development.
What is the difference between CHAR_LENGTH and LENGTH?
The first is, naturally, the character count. The second is byte count. For the Latin characters the numbers are the same, but they’re not the same for Unicode and other encodings.
How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
What Is a Session?
A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.
There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.
Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.
What is meant by PEAR in php?
Answer1:
PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install packages
Answer2:
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.
How can we know the number of days between two given dates using PHP?
Simple arithmetic:
$date1 = date(’Y-m-d’);
$date2 = ‘2006-07-01′;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo Number of days since ‘2006-07-01′: $days;
How can we repair a MySQL table?
The syntex for repairing a mysql table is:
REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED
This command will repair the table specified.
If QUICK is given, MySQL will do a repair of only the index tree.
If EXTENDED is given, it will create index row by row.
What is the difference between $message and $$message?
Anwser 1:
$message is a simple variable whereas $$message is a reference variable. Example:
$user = ‘bob’
is equivalent to
$holder = ‘user’;
$$holder = ‘bob’;
Anwser 2:
They are both variables. But $message is a variable with a fixed name. $$message is a variable who’s name is stored in $message. For example, if $message contains var, $$message is the same as $var.
What Is a Persistent Cookie?
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
What does a special set of tags do in PHP?
What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
How do you define a constant?
Via define() directive, like define (MYCONSTANT, 100);
What are the differences between require and include, include_once?
Anwser 1:
require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:
All three are used to an include file into the current page.
If the file is not present, require(), calls a fatal error, while in include() does not.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
What is meant by urlencode and urldecode?
Anwser 1:
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(10.00%) will return 10%2E00%25?. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Anwser 2:
string urlencode(str) Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:
Alphanumeric characters are maintained as is.
Space characters are converted to + characters.
Other non-alphanumeric characters are converted % followed by two hex digits representing the converted character.
string urldecode(str) Returns the original string of the input URL encoded string.
For example:
$discount =10.00%;
$url = http://domain.com/submit.php?disc=.urlencode($discount);
echo $url;
You will get http://domain.com/submit.php?disc=10%2E00%25?.
How To Get the Uploaded File Information in the Receiving Script?
Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] The Original file name on the browser system.
$_FILES[$fieldName]['type'] The file type determined by the browser.
$_FILES[$fieldName]['size'] The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] The error code associated with this file upload.
The $fieldName is the name used in the <INPUT,>.
What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array
How can I execute a PHP script using command line?
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.
How to get size & type of uploaded image?
list($width, $height, $type) = getimagesize($_FILES['photo_file']['tmp_name']);
How can we submit a form without a submit button?
The main idea behind this is to use Java script submit( function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit( method to onclick, onchange events of different inputs and perform the form submission. you
can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites.
In how many ways we can retrieve the data in the result set of MySQL using PHP?
You can do it by Ways
. mysql_fetch_row.
. mysql_fetch_array
. mysql_fetch_object
. mysql_fetch_assoc
What is the difference between mysql_fetch_object and mysql_fetch_array?
mysql_fetch_object( is similar tomysql_fetch_array(, with one difference – an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names.
What is the difference between $message and $$message?
It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan
with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?
preg_match(”/^http:\/\/.+@(.+$/”,’http://info@abc.com’,$found;
echo $found[];
How can we create a database using PHP and MySQL?
We can create MySQL database with the use of
mysql_create_db(“Database Name”
What are the differences between require and include, include_once and require_once?
The include( statement includes and evaluates the specified file.The documentation below also applies to require(. The two constructs are identical in every way except how they handlefailure. include( produces a Warning while require( results in a Fatal Error. In other words, use require( if you want a missingfile to halt processing of the page.
include( does not behave this way, the script will continue regardless.
The include_once( statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include( statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once( should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once( should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
Can we use include (”abc.PHP” two times in a PHP page “makeit.PHP”?
Yes we can use include( more than one time in any page though it is not a very good practice.
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(,ename varchar(0 ?
Total types of tables we can create
. MyISAM
. Heap
. Merge
. INNO DB
. ISAM
MyISAM is the default storage engine as of MySQL . and as a result if we do not specify the table name explicitly it will be assigned to the default engine.
0
How can we encrypt the username and password using PHP?
0
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption
AES_ENCRYT( AES_DECRYPT(
ENCODE( DECODE(
DES_ENCRYPT( DES_DECRYPT(
ENCRYPT( Not available
MD( Not available
OLD_PASSWORD( Not available
PASSWORD( Not available
SHA( or SHA( Not available
Not available UNCOMPRESSED_LENGTH(
How are ENUMs and SETs represented internally?
As unique integers representing the powers of two, due to storage optimizations.
How do you start and stop MySQL on Windows?
net start MySQL, net stop MySQL
How do you start MySQL on Linux?
/etc/init.d/mysql start
Explain the difference between mysql and mysql interfaces in PHP?
mysqli is the object-oriented version of mysql library functions.
What’s the default port for MySQL Server?
0
What does tee command do in MySQL?
tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command note.
Can you save your connection settings to a conf file?
Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 00, so that it’s not readable by others.
How do you change a password for an existing user via mysqladmin?
mysqladmin -u root -p password “newpassword”
Use mysqldump to create a copy of the database?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
Have you ever used MySQL Administrator and MySQL Query Browser?
Describe the tasks you accomplished with these tools.
0 What are some good ideas regarding user security in MySQL?
There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet. There are as few users as possible (in the ideal case only root who have unrestricted access.
Explain the difference between MyISAM Static and MyISAM Dynamic. ?
In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.
What does myisamchk do?
It compressed the MyISAM tables, which reduces their disk usage.
Explain advantages of InnoDB over MyISAM?
Row-level locking, transactions, foreign key constraints and crash recovery.
Explain advantages of MyISAM over InnoDB?
Much more conservative approach to disk space management – each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy ,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*s execute slower than in MyISAM due to tablespace complexity.
What are HEAP tables in MySQL?
HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
How do you control the max size of a HEAP table?
MySQL config variable max_heap_table_size.
What are CSV tables?
Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
Explain federated tables. ?
Introduced in MySQL .0, federated tables allow access to the tables located on other databases on other servers.
What is SERIAL data type in MySQL?
BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
0 What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table?
It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
Explain the difference between BOOL, TINYINT and BIT. ?
Prior to MySQL .0.: those are all synonyms. After MySQL .0.: BIT data type can store bytes of data and should be used for binary data.
Explain the difference between FLOAT, DOUBLE and REAL. ?
FLOATs store floating point numbers with place accuracy and take up bytes. DOUBLEs store floating point numbers with place accuracy and take up bytes. REAL is a synonym of FLOAT for now.
If you specify the data type as DECIMAL (,, what’s the range of values that can go in this table?
. to -.. Note that with the negative number the minus sign is considered one of the digits.
What happens if a table has one column defined as TIMESTAMP?
That field gets the current timestamp whenever the row gets altered.
But what if you really want to store the timestamp data, such as the publication date of the article?
Create two columns of type TIMESTAMP and use the second one for your real data.
Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ?
The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.
What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do?
On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
Explain TIMESTAMP DEFAULT ‘00:0:0 ::? ON UPDATE CURRENT_TIMESTAMP. ?
A default value is used on initialization, a current timestamp is inserted on update of the row.
If I created a column with data type VARCHAR(, what would I expect to see in MySQL table?
CHAR(, since MySQL automatically adjusted the data type.
General Information About MySQL
MySQL is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language database server.
0 MySQL is free software.
It is licensed with the GNU GENERAL PUBLIC LICENSE http://www.gnu.org/.
What Is MySQL
MySQL, the most popular Open Source SQL database, is provided by MySQL AB. MySQL AB is a commercial company that builds is business providing services around the MySQL database. See section . What Is MySQL AB.
MySQL is a database management system.
A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL. Since computers are very good at handling large amounts of data, database management plays a central role in computing, as stand-alone utilities, or as parts of other applications.
MySQL is a relational database management system.
A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The tables are linked by defined relations making it possible to combine data from several tables on request. The SQL part of MySQL stands for “Structured Query Language” – the most common standardized language used to access databases.
MySQL is Open Source Software.
Open source means that it is possible for anyone to use and modify. Anybody can download MySQL from the Internet and use it without paying anything. Anybody so inclined can study the source code and change it to fit their needs. MySQL uses the GPL (GNU General Public License http://www.gnu.org, to define what you may and may not do with the software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL into a commercial application you can buy a commercially licensed version from us.
Why use MySQL?
MySQL is very fast, reliable, and easy to use. If that is what you are looking for, you should give it a try. MySQL also has a very practical set of features developed in very close cooperation with our users. You can find a performance comparison of MySQL to some other database managers on our benchmark page. See section . Using Your Own Benchmarks. MySQL was originally developed to handle very large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Though under constant development, MySQL today offers a rich and very useful set of functions. The connectivity, speed, and security make MySQL highly suited for accessing databases on the Internet.
The technical features of MySQL
For advanced technical information, see section MySQL Language Reference. MySQL is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and a programming interface. We also provide MySQL as a multi-threaded library which you can link into your application to get a smaller, faster, easier to manage product. MySQL has a lot of contributed software available.
It is very likely that you will find that your favorite application/language already supports MySQL. The official way to pronounce MySQL is “My Ess Que Ell” (not MY-SEQUEL. But we try to avoid correcting people who say MY-SEQUEL.
Session and cookie
What is the difference between session and cookie ?
flash
How can we call flash banner in dreamweaver..
php swapp two name surmane
why we use @?
Give the ans.
what is the difference between sql and mysql
SQL means “structured query language” which is the syntax of commands you send to database. MYSQL is the database program which accepts the those commands and gives out the data.
Please Help
I have created a php site in dreamweaver but i have not stored the files in www directory of wamp. now i want to move the files to www directory without losing the links that i’ve created… how is it possible??
How i get DPI of uploaded image
Can any one tell me how can i get DPI of uploaded image. Thanx
zend framework
Hi evryone, how do i call stored procedure from zend framework using oracle database and how to echo the data. muzeeb
what is the difference between echo and print in php?
When outputting something with PHP, we use print or echo functions. what exactly is the difference between those functions?
PHP – Drupal Joomla Developer required 2 – 3 Years Experienced – MNC Bangalore
Please send your resumes for the Drupal Joomla Opening – Reputed Company – Bangalore Requirement: 2 – 3 years experience in Joomla / Drupal & PHP Contact on bshibin@gmail.com
difference between superkey candidate and primary keys
Super key is the set of attributes in a table that can uniquely identifies a database tuple(row or record). Candidate key is the minimal set of super key that can uniquely identifies a database record. Primary key is one of the candidate keys. you can select any candidate k
Custom redirect in drupal after the node is created?
Please use the following snippet for the custom redirect. function module_form_alter(&$form,$form_state,$form_id){ if (isset($form['#node']) && $form['#node']->type .’_node_form’ == $form_id) { $form['buttons']['submit']['#submit'][] = ‘module_redirect_handler’; }
How to enable HTML option for Drupal menus?
/* *Enabling HTML option for Drupal menus */ function theme_menu_item_link($link) { $link['localized_options']['html'] = true; return l($link['title'], $link['href'], $link['localized_options']); }
Why “pageTracker is not defined” error when using pageTracker._trackPageLoadTime();?
Please try use _gaq.push([‘_trackPageLoadTime’]); instead. It will work !!!
Why mousewheel.js/Jscrollpane.js ( scrolloing using mouse wheel ) not working in Firefox?
It might be because of Jscrollpane.js issue. The Quick solution to solve this issue is to edit the Jscroolpane.js. Go to particular line number ( Mostly:341 ) and change to var dragOffset = $drag.offset(false); currentOffset = { top: dragOffset.top, left:dragOffse
How to create admin settings form in Drupal?
How to extract content between anchor tags using Javascript?
In Jquery we can follow the following to iterate the contents.
Why “#” needs to be encoded in the URLs?
If you are using any “#” in the URLs it should be in the encoded form. Its because of this is used in URLs to mention where the fragment indicators ( eg:bookmarks or anchors in HTML ) begins in URLs.
Checking whether your MySQL server supports partitioning?
Before implementing any user defined partitioning in MySQL we need to make sure whether your mysql server supports partitioning. Finding out the same in your server will be simple. Type SHOW VARIABLES LIKE ‘%partition%’; on the command prompt as shown below. mysql> SHOW
why $_POST is better even though view source of the form gives the details
Plz some one give me the answer
Advantages of MySQL 5.1 compared to MySQL 5
Please find the following features that has been added to the MySQL version 5.1. 1. Partitioning 2. Row Based Replication 3. Plugin API 4. Server log table 5. Upgrade program 6. MySQL Cluster 7. Backup of tablespaces 8. Improvements to INFORMATION_SCHEMA 9. XML functio
disable the drupal cache for a page and for a module in drupal site
There is a contributed module to exclude drupal cache for particular pages in your drupal site. you can find the module in http://drupal.org/project/cacheexclude . for excluding drupal cache for a particular module write the below mentioned code in ur modulename_init() hook
How to send mail using MSSQL Express edition
I need to know the use of MS Sql express edition for sending mails.
Caching – How caching is implemented in Drupal?
For improving the the performance of the Drupal site we can use the caching mechanism. In caching rather than extracting the same data again and again every time, it stores the frequentltay accessed and static data in a convenient place and format. Drawback of caching is that,
Recommend commonly used modules for Drupal?
When an interviewer is asking these question please make sure before recommending any module 1. Whats the use of that module? 2. How well it is supported? 3. Any Vulnerabilities with the module?
Drupal – Overriding style sheets from modules and drupal core
Option 1 To override a core or contributed module style sheet, it must be specified in your theme’s .info file. For example, system-menus.css is located at “modules/system/system-menus.css”. If you place a file with the same name in your theme’s folder and add the following ent
Drupal – Overriding Drupal Core Javascript Files?
cognizant php interview questions?
Do any one have Cognizant/Capgemini interview questions for php/Drupal?
Openings with TCS BPO
Start Career With TCS Walk-in for graduates from the Batch 2010 and 2011 BA/BBA/BBM/B Com/BSc/MSc ( Statistics/Maths ) / M.Com On Saturday 16th April 2011 At TCS, Think Campus,#42, Electronic City, Phase II, Bangalore 100
Why the drupal blocks are disappearing after submitting the form?
Why the drupal blocks are disappearing after submitting the form?
Why the drupal blocks are disappearing after submitting the form?
Do any one have any idea why the blocks are disappearing?
How to create a new region in Drupal 6?
Please follow the following steps to create new regions for Drupal 6 ADD the following region information to you theme.info file: regions[left] = Left sidebar regions[right] = Right sidebar regions[content] = Content regions[header] = Header regions[footer] = Foote
how i can show msg for user when someone try to login
Hello everybody ..! :D i’m working on a E-Bank project , and i need script to show msg for the user when some try to login in at the same username and password at the same time ? Best Regards ..!
Altering form in drupal?
Hook_form_alter Drupal hook function or hook_form_alter(&$form, &$form_state, $form_id) Perform alterations before a form is rendered. One popular use of this hook is to add form elements to the node form. When altering a node form, the node object ca
What is AJAX?
Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire w
What is the difference between constructors in PHP4 & PHP5?
Constructors – PHP4 Constructors are functions in a class that are automatically called when you create a new instance of a class with new. A function becomes a constructor, when it has the same name as the class. If a class has no constructor, the constructor of the base cla
What is meant by Exceptional Handling?
Exceptions PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, try and caught within PHP. A Try block must include at least one catch block. Multiple catch blocks can be used to catch different classtypes; execution will co
What is meant by Virtual hosting?
Virtual hosting HTTP includes the concept of virtual hosting, where a single HTTP server can represent multiple hosts at the same IP address. A DNS server can allocate several different host names to the same IP address. When an HTTP client ma
What is meant by Session Clustering?
The Session Manager session support allows multiple server instances to share a common pool of sessions, known as a session cluster Session clustering setting up methods :
How does Database handle Sessions?
As you should be aware the HTTP protocol, as used for serving web pages, is completely stateless. This means that after the server has received a request, processed it and sent a response, the process which dealt with that request dies. Anything that
What is the difference between include and include_once?
Include() The include() statement includes and evaluates the specified file. This also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error.
Tell me some thing about mod_rewrite and url rewriting?
Mod_rewrite *************
What are static methods?
Static Keyword Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can). The static declar
What is Phishing?
In computing, phishing is a form of criminal activity using social engineering techniques. It is characterized by attempts to fraudulently acquire sensitive information, such as passwords and credit card details, by masquerading as a trustworthy person or business in an ap
Do you know about Cross site Scripting ?
Cross-site scripting (XSS) is a security exploit in which the attacker inserts malicious coding into an link that appears to be from a trustworthy
What is session hijacking?
Session hijacking, also known as TCP session hijacking, is a method of taking over a Web user session by surreptitiously obtaining the session ID and masquerading as the authorized user. Once the user’s session ID has been accessed (through session prediction), the attacker
Authentication – General Definition
Authentication is the process of determining whether someone or something is, in fact, who or what it is declared to be. In private and public computer networks (including the Internet), authentication is commonly done through the use of logon passwords. Knowledge of the p
What is smarty?
Smarty is a template engine written in PHP. Typically, these templates will include variables —such as {$variable}— and a range of logical and loop operators to allow adaptability within of the template.
What is Model-view-controller (MVC)?
Model-view-controller (MVC) is a design pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (model) and user interface (view) concerns, so that changes to the user interface do not
What is the difference between mysql_fetch_object and mysql_fetch_array?
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. mysql_fetch_object() example
How can we submit a form without a submit button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form
What is the difference between GET and POST methods in form submitting? Give the cases where we can use GET and POST methods?
The main difference between GET and POST is how the form data is passing. Both are used for passing form field values. All the values which is submitted by the GET method will be appended to the URL. Where as POST method send the data with out appending the URL(
What is the difference between strstr() and stristr()?
Strstr — Find first occurrence of a string strstr() example stristr — Case-insensitive strstr() stristr() example
What is meant by PEAR in php?
PEAR PHP Extension and Application Repository PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wiz
How can we know the count/number of elements of an array?
A) sizeof($urarray) This function is an alias of count() b) count($urarray)
What is the difference between the functions unlink() and unset()?
Unlink is a function for file system handling. It will simply delete the file in context unset will set UNSET the variable
What is meant by urlencode and urldecode?
String urlencode(str) where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world string urldocode(str)
How can we repair a MySQL table?
The syntex for repairing a mysql table is REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended] This command will repair the table specified if the quick is given the mysql will do a repair of only the index tree if the extended is given it will create in
What is the maximum length for database, table & column names?
database- 64 table -64 columns-64 alias-255
What are the commands to find the structure of a MySQL table other than EXPLAIN command?
Describe table_name
What is the difference between char and varchar data types?
Set char to occupy n bytes and it will take n bytes even if u r storing avalue of n-m bytes Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes eg. name char(10) will waste 5 bytes if we store ‘testname&rsqu
What is the functionality of md5 function in PHP?
Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number.
What is the difference between GROUP BY and ORDER BY in MySQL?
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
What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transm
Is it possible to pass data from JavaScript to PHP?
A. Yes, but not without sending another HTTP request. B. Yes, because PHP executes before JavaScript. C. No, because JavaScript is ser
what is session_start() ?
When a user first encounters a page in your application that call ssession start(),a sessionis created for the user.PHP generates a random session identifier to identify the user,and then it sends a set-Cookieheader to the client.By default,the name of this cookie is PHPSE
How do you convert an old fashioned 10 digit ISBN to a new 13 digit ISBN using php ?
function isbn10_to_13($isbnold){ if (strlen($isbnold) != 10){ // Make sure we have a 10 digit string to start return ‘Invalid ISBN-10
What’s foreign data in php?
* Anything from a form * Anything from $_GET, $_POST, $_REQUEST * Cookies ($_COOKIES) * Web services data * Files
What is str_split function in php?
According to PHP official manual It is used to converts a string to an array. If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character
How can we encrypt and decrypt a data present in a MySQL table using MySQL?
There are two methods AES_ENCRYPT () and AES_DECRYPT ()
How can we find the number of rows in a table using MySQL?
SELECT COUNT(*) FROM tb_nme;
Where MyISAM table is stored ?
Each MyISAM table is stored on disk in three files. The ‘.frm&r
How many types of buffers does use MySQL?
Global buffers and per-connection buffers
what is the use of –i-am-a-dummy flag in MySql?
It Makes the MySQL engine refuse UPDATE and DELETE commands where the WHERE clause is not present.
Is MySQL better than MSSQL ?
Mysql is the most popular open source database server right now. It is used by large enteprise level companies and small, single websites. Is mysql actually better? ——————————— Mysql 5.
What is the Use of “WITH ROLLUP” in Mysql?
http://www.w3answers.com
How to determine the number of rows in the full result set and also restrict the number of rows that a query returns….
How to determine the number of rows in the full result set and also restrict the number of rows that a query returns,without running a second query ? Most of the developers using 2 queries to find total numbe
What is the maximum length of a table name, a database name, or a field name in MySQL?
Database name: 64 characters Table name: 64 characters Column name: 64 characters
How many values can the SET function of MySQL take?
MySQL SET function can take zero or more values, but at the maximum it can take 64 values.
How many ways we can we find the current date using MySQL?
SELECT CURTIME(); SELECT CURDATE(); SELECT CURRENT_TIME();
What is the difference between CHAR and VARCHAR data types?
Ans: CHAR is a fixed length data type.
How can we know the number of days between two given dates using MySQL?
Using DATEDIFF() SELECT DATEDIFF(NOW(),’2007-07-15′);
what is database testing and what we test in database testing?
Database testing basically include the following. 1)Data validity testing. 2)Data Integritity testing 3)Performance related to data base. 4)Testing of Procedure,triggers and functions. for doing data validity testing you should be good in SQL q
How can we take a backup of mysql table and restore it?
These are the simplest method to backup and restore the MySQl table For taking the bakup of all the databases mysqldump –user {user
Is it possible to set a time expire page in PHP.?
Yes it is Using header(“Expires: Mon, 26 Jul 2007 05:00:00 GMT&qu
How can we save an image from a remote web server to my web server using PHP?
what is the output of 2^2 in php ?
The answer is 0 (Zero) Important note Everyone expected answer would be 4.But answer is zero.How it happened only in php ? The ^ oper
what is the output of below script?
a. echo ‘line 3′; b. echo ‘line 2′; c. Error d. None of the above Ans: b (Answer is line2)
What is the output here?
a. hello sunil b. Parse error c. hello $x d. syntax error ANS: c published by http://www.w3answers.com
Tutoring Online – Cookies and Sessions
Hi my dear friends. Everybody knows what is cookie and session. But let me tell a truth, most of the beginners don’t know properly what is happening in cookies and sessions and what is the real use .I have taken so many Interviews but none of them given a good
What is PHP?
PHP: Hypertext Preprocessor, an open source, server-side, HTML embedded scripting language used to create dynamic Web pages.
What can PHP do?
Anything. PHP is mainly focused on server-side scripting, so you can do anything any other CGI program can do, such as coll
Your first PHP script – “Hello World”
PHP Test
How we can pass data from PHP to ASP,ASP.net?
PHP to ASP Let’s first look at how you can pass data from PHP to ASP using WDDX. You create a WDDX packet by first serializi
How can you block certain IP Addresses from accessing your site?
What Storage Engines do you use in MySQL?
MySQL Engines
What is Apache?
The most widely available HTTP server on the Internet. It supports the PERL and PHP languages.
Installing PHP on your Computer?
You can download apache2triad from
How to convert ASP Arrays to PHP and viceversa ?
ASP Arrays to PHP WDDX also allows more-complicated data structures to be passed between applications. Here we will pass an array from an ASP WDDX script to a PHP script.
Which of the following represents the proper way to set a session variable?
A. $_SESSION[‘foo’] = ‘bar’; B. session_start(); C. session_set_save_handler (‘myopen’, ‘myclose’, ‘myread’, ‘mywrite’, ‘mydelete’, ‘mygarbage&
PHP Functions for WDDX
PHP has a few other functions that can be useful when you’re working with WDDX:
what output do you get here?
a. home b. Array c. test d. httpd ANS: httpd
Which of the following functions is most efficient for substituting fixed patterns in strings?
A. preg_replace() B. str_replace() C. str_ireplace() D. substr_replace()
Which function in PHP gives us absolute path of a file on the server?
Ans: getcwd() Here I have stored my files under httdocs (using php5,i haven’t checked under php4) so I get the output as C:\apache2triad\htdocs you may get your path information while runnings the above code. :)
what is the output here ?
The output : http://www.w3answers.com and warning as below Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advise
what is the output ?
a. ouch b. echo c. none d. Parse error ANS: a
How can we extract string “w3answers.com” from a string mailto:info@w3answers.com using regular expression of PHP ?
Answer: <?php $w3 = “mailto:info@w3answers.com”; preg_match(‘|.*@([^?]*)|’,$w3,$w3output); echo $w3output[1]; ?>
Why should we use Object oriented concepts in php ?
1. Object oriented PHP code is much more reusable because by its’ very nature, it is modular. 2. Object oriented PHP is easier to update. Again, because PHP code is organised into objects. 3. Object oriented PHP makes team programming much easier
which is faster mysql_unbuffered_query or mysql_query ?
When we do the select queries that retrieve large data sets from MySQL, mysql_unbuffered_query in PHP is likely to give better performance than mysql_query. PHP manual says, it “sends a SQL query query to MySQL, without fetching
How to capture content from the output buffer ? or Give me an example for Output caching in php?
What is the difference between $message and $$message?
$message is a simple variable whereas $$message is a variable’s variable,which means value of the variable. Example: $user = ‘bob’ is equivalent to $message = ‘user’; $$message = ‘bob’;
what is the php solution to dynamic caching ?
PHP offers an extremely simple solution to dynamic caching in the form of output buffering.
what are the most common caching policy approaches ?
1)Time triggered caching (expiry timestamp). 2)Content change triggered caching (sensitive content has changed, so cache must be updated). 3)Manually triggered caching (man
What Are PHP Arrays?
PHP arrays are associative arrays with a little extra machinery thrown in. The associative part means that arrays store element values in association with key values rather than in a strict linear index order. (If y
Are php strings immutable ?
PHP strings can be changed, but the most common practice seems to be to treat strings as immutable.Strings can be changed by treating them as character arrays and assigning directly into them, like this:
What is Memcache?
Memcache is a technology which caches objects in memory where your web application can get to them really fast. It is used by sites such as Digg.com, Facebook.com and NowPublic.com and is widely recognized as an essential ingredient in scaling any LAMP
How do I prevent Web browsers caching a page in php?
What is the process that takes place when you upload a file in php?
There are two basic things covered here. The form that will be used to post the file data to and the actual program that does the uploading. Further we will discuss the method that PHP itself suggests for uploading files. Process 1 HTML PART
Will persistent connection work in the CGI version of php ? mysql_connect() vs mysql_pconnect()?
Persistent database connections work only in the module installation of PHP. If you ask for a persistent connection in the CGI version, you will simply get a regular connection.
What are the ‘function problems’ you have met in php?
1)Call to undefined function we_w3answers() PHP is trying to call the function we_w3answers(), which has not been because you misspelled the name of a function (built-in or use
Explain Parse Errors ? what are the most common causes of parse errors ?
The most common category of error arises from mistyped or syntactically incorrect PHP code, which confuses the PHP parsing engine. 1)The missing semicolon If each PHP instruction is not duly finished off with a semicolon, a parse e
List out some session functions in php?
session_save_path — Get and/or set the current session save path session_is_registered — Find out whether a global variable is registered in a session session_unset — Free all session variables session_cache_expire — Ret
What is meant by Persistent Database Connections?
How many ways your web server can utilize PHP to generate web pages?
Mainly there are three ways
How to opening excel files in windows nad linux using php ?
if you’re using PHP on Windows, you can use the inbuilt COM library $excel = ne
what are the ways to check image mime types in php?
There are a few inbuilt options you can use however, for example getimagesize() can return the mimetype, as does some of the new fileinfo functions. The mime type in getimagesize is stored in ‘mime’, and can be accessed as shown below.
Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
$stringOfText = “<p>This is a test</p>”; $expression = “/<
what you should know about cookies before start using in php?
There are a few things you should be aware of: 1. Since cookies are used to record info
what are the database space-saving functions available in php ?
# Use ip2long() and long2ip() to store the IP adresses as Integers instead of storing them as strings, which will reduce the
what are the security tips you should know before developing php/mysql web pages ?
1. Do not trust user input. 2. Validate user input on the server side. 3. Do not use user input directly in your MySQL queries. 4. Don’t put integers in quotes In your MySQL queries. 5. Always escape the output using ph
How to get the contents of a web page using php?
You can achieve this using curl in php see the example below.
what are the advantages of storing sessions in database?
If you store a session in a database you have several advantages:
How many HTTP headers will send to a web page(client side) from server when you use sessions (session_start()) in php ?
There are three HTTP headers included in the response: Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache
php supports following database
A) Solid & oracle b) mysql c) None of the above d) All of the above All of the above
PHP comments will be?
A) // b) /* fgfg */ c) All of the above d) First one ANS: All of the above
What is the output for the following script ?
a) syntax error b) runtime error c) all of the above d) hihihi welcome hihihi ANS: d
what is the output below mentioned?
a) String not matched b) Match found c) All of the above d) None of the above ANS : b (no
what is the output below mentioned ?
a) Error b) APPLE c) Apple d) None of the above ANS : APPLE
what is the output below mentioned?
a) mmer b) mer c) all of the above d) none of the above ANS: none of the above NOTE: if we execute the above code we get the output as ‘m programmer’
what is the output here?
a) false b) true c) error d) declaration error ANS : true
what output do you get here?
Www.w3answers.com w3answers.blogspot.com Ans:Array NOTE: use ‘foreach($r as $v)’ then try to output value ‘echo $v’ or use Print_r($r) so if we make above script as
what is scandir() ?
Www.w3answers.com List files and directories inside the specified path By default files order will be ascending $f = scandir($direct, 1); it will display the files as descending order
What function would you use to redirect the browser to a new page?
1. redir() 2. header() 3. location() 4. redirect() ANS:header()
What function can you use to open a file for reading and writing?
1. fget(); 2. file_open(); 3. fopen(); 4. open_file(); ANS:fopen();
How can you get round the stateless nature of HTTP using PHP?
ANS: using Sessions in PHP
What would the following code print to the browser? Why?
Ans: 10 because,its a call by value.$num is static here. change the above code as
What are the different functions in sorting an array?
Ans:
How can we know the number of elements in an array using php?
Ans:There are two ways: 1) sizeof($myarray) – This function is an alias of count() 2) count($array) – This function returns the number of elements in an array. Note if you just pass a simple variable instead of an array, count() will retur
How can we know the number of elements in an array using php?
Ans: There are two ways: 1) sizeof($myarray) – This function is an alias of count() 2) count($array) – This function returns the number of elements in an array. Note if you just pass a simple variable instead of an array, count() will return 1.
How can we get second of the current time using date function?
What will be the following script output?
A. 2 B. 1 C. Null D. True E. 3 Answer A is correct. Because of operator precedence, the modulus operation is performed first, yielding a result of 2 (the remainder of the division of 5 by 2). Then, the result of this operation is
Which data type will the $a variable have at the end of the following script?
A. (int) 1 B. (string) “1” C. (bool) True D. (float) 1.0 E. (float) 1 Answer B is correct. When a numeric string is assigned to a variable, it remains a string, and it is not converted until needed because of an operation that
What will be the following script output?
A. 2 B. 1 C. 3 D. 0 E. Null Answer B is correct.
what is ajax? when ajax was born?
“AJAX is an acronym for Asynchronous JavaScript and XML. If you think it doesn’t say much, we agree. Simply put, AJAX can be read “empowered JavaScript”, because it essentially offers a technique for client-side JavaScript to make background server calls(such as from PHP,ASP.NET,
What API function provides the connection between the client and server?
ANS:XMLHttpRequest
Should I use an HTTP GET or POST for my AJAX calls?
AJAX requests should use an HTTP GET request when retrieving data where the data will not change for a given request URL. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idem potency recommendations and is highly recommended for a consis
What is MySQL?
MySQL (pronounced “my ess cue el”) is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL a
What Is a Persistent Cookie?
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser’s computer. By default, cookies are created as temporary cookies which stored only in the browser’s memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
What does a special set of tags do in PHP?
What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
How do you define a constant?
Via define() directive, like define (”MYCONSTANT”, 100);
What are the differences between require and include, include_once?
Anwser 1:
require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:
All three are used to an include file into the current page.
If the file is not present, require(), calls a fatal error, while in include() does not.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
What is meant by urlencode and urldecode?
Anwser 1:
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(”10.00%”) will return “10%2E00%25″. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Anwser 2:
string urlencode(str) – Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version:
Alphanumeric characters are maintained as is.
Space characters are converted to “+” characters.
Other non-alphanumeric characters are converted “%” followed by two hex digits representing the converted character.
string urldecode(str) – Returns the original string of the input URL encoded string.
For example:
$discount =”10.00%”;
$url = “http://domain.com/submit.php?disc=”.urlencode($discount);
echo $url;
You will get “http://domain.com/submit.php?disc=10%2E00%25″.
How To Get the Uploaded File Information in the Receiving Script?
Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] – The Original file name on the browser system.
$_FILES[$fieldName]['type'] – The file type determined by the browser.
$_FILES[$fieldName]['size'] – The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] – The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] – The error code associated with this file upload.
The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>.
What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array
How can I execute a PHP script using command line?
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.
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.
Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example?
In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like “{$a},000,000 mln dollars”, then you definitely need to use the braces.
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))?
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23. When you fire the above create query MySQL will create a MyISAM table.
How To Create a Table?
If you want to create a table, you can run the CREATE TABLE statement as shown in the following sample script:
<?php
include “mysql_connection.php”;
$sql = “CREATE TABLE fyi_links (”
. ” id INTEGER NOT NULL”
. “, url VARCHAR(80) NOT NULL”
. “, notes VARCHAR(1024)”
. “, counts INTEGER”
. “, time TIMESTAMP DEFAULT sysdate()”
. “)”;
if (mysql_query($sql, $con)) {
print(”Table fyi_links created.\n”);
} else {
print(”Table creation failed.\n”);
}
mysql_close($con);
?>
Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script, you will get something like this:
Table fyi_links created.
How can we encrypt the username and password using PHP?
Answer1
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(”Password”);
Answer2
You can use the MySQL PASSWORD() function to encrypt username and password. For example,
INSERT into user (password, …) VALUES (PASSWORD($password”)), …);
How do you pass a variable by value?
Just like in C++, put an ampersand in front of it, like $a = &$b
WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?
string strstr ( string haystack, string needle ) returns part of haystack string from the first occurrence of needle to the end of haystack. This function is case-sensitive.
stristr() is idential to strstr() except that it is case insensitive.
When are you supposed to use endif to end the conditional statement?
When the original if was followed by : and then the code block without braces.
How can we send mail using JavaScript?
No. There is no way to send emails directly using JavaScript.
But you can use JavaScript to execute a client side email program send the email using the “mailto” code. Here is an example:
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location=”mailto:mailid@domain.com?subject=…”;
return true;
}
What is the functionality of the function strstr and stristr?
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example: strstr(”user@example.com”,”@”) will return “@example.com”.
stristr() is idential to strstr() except that it is case insensitive.
What is the difference between ereg_replace() and eregi_replace()?
eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.
How do I find out the number of parameters passed into function9. ?
func_num_args() function returns the number of parameters passed in.
What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
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,
If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
5, it’s a reference to existing variable.
No comments:
Post a Comment