|
what is '1000 projects'?
'fullinterview.com' is a educational content website dedicated to finding and realizing final year projects for btech, be, mtech, mca students, here you can search, find your projects and get guidance from experts the below are the different technological projects.
visual Studio projects
.net projects,
asp projects,
c & ds projects,
c++ projects (all),
cold fusion projects,
delphi projects,
java projects,
perl projects,
php projects,
sql projects,
vc++ projects,
visual basic projects.
how it works?
well, everything on this site is submitted by the student and professional community. after you submit your project, it is being verified and approved by our administrator. after approval, other people can read/discuss it, save to favorites.
more number of projects?
here you can find morethan 1000 projects on different technologies, if u want to get more projects please visit our sister sites www.fullinterview.com & Chetanasprojects.com
Category Articles
How To Remove Slashes on Submitted Input Values?
Added on Tue, Jan 5, 2010
By default, when input values are submitted to the PHP engine, it will add slashes to protect single quotes and double quotes. You should remove those slashes to get the original values by applying the stripslashes() function. Note that... Read More
How can I embed a java programme in php file and what changes have to be done in php.ini file?
Added on Sun, Jan 3, 2010
There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment, which is the more stable and efficient solution, or integrate Java support into PHP. The former is provided... Read More
When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?
Added on Mon, Jan 4, 2010
Answer: Using Html font color tag: <font color=RED> I am Amin </font> Using tag in CSS: STRONG {color:red} So when we use the <STRONG> tag: I am <STRONG>Amin</STRONG> about... Read More
Why doesn’t the following code print the newline properly?
Added on Wed, Jan 6, 2010
<?php $str = ‘Hello, there.nHow are you?nThanks for visiting TechInterviews’; print $str; ?> Because inside the single quotes the n character is not interpreted as newline, just as a sequence... Read More
How To Create a Table?
Added on Sun, Jan 3, 2010
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" . ",... Read More
What are the reasons for selecting LAMP (Linux, Apache, MySQL, Php) instead of combination of other software programs, servers and operating systems?
Added on Sun, Jan 3, 2010
All of those are open source resource. Security of linux is very very more than windows. Apache is a better server that IIS both in functionality and security. Mysql is world most popular open source database. Php is more faster that... Read More
How can I make a script that can be bilingual (supports English, German)?
Added on Sun, Jan 3, 2010
You can change charset variable in above line in the script to support bilanguage. Read More
What's PHP
Added on Sun, Jan 3, 2010
The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. Read More
Will comparison of string "10" and integer 11 work in PHP?
Added on Sun, Jan 3, 2010
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared. Read More
Explain different types of errors in php (i.e. arguments in error reporting function)?
Added on Mon, Jan 4, 2010
Answer: Three are three types of errors: 1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By... Read More
When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching?
Added on Mon, Jan 4, 2010
How can you prevent caching of a certain page (please give several alternate solutions)? Answer: When you use the <HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> metatag in the header section at the beginning of... Read More
What are the differences between public, private, protected, static, transient, final and volatile?
Added on Mon, Jan 4, 2010
element Class Interface Data field Method Constructor modifier top level nested top level nested (outer) (inner) (outer) (inner) final yes yes no yes yes no no private yes yes yes no yes no yes ... Read More
How can we know the number of days between two given dates using PHP?
Added on Sun, Jan 3, 2010
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"; Read More
When are you supposed to use endif to end the conditional statement? -
Added on Wed, Jan 6, 2010
When the original if was followed by : and then the code block without braces. Read More
How do I find out the number of parameters passed into function9. ?
Added on Sun, Jan 3, 2010
func_num_args() function returns the number of parameters passed in. Read More
How To Detect File Uploading Errors?
Added on Wed, Jan 6, 2010
If there was a problem for a file upload request specified by the <INPUT TYPE=FILE NAME=fieldName...> tag, an error code will be available in $_FILES[$fieldName]['error']. Possible error code values are: ... Read More
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))?
Added on Sun, Jan 3, 2010
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. Read More
How can we register the variables into a session?
Added on Sun, Jan 3, 2010
session_register($session_var); $_SESSION['var'] = 'value'; Read More
What Is a Session?
Added on Sun, Jan 3, 2010
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... Read More
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
Added on Sun, Jan 3, 2010
Here are three basic types of runtime errors in PHP: 1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default,... Read More
How can we repair a MySQL table?
Added on Sun, Jan 3, 2010
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... Read More
How can we submit form without a submit button?
Added on Sun, Jan 3, 2010
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. For example: <input type=button value="Save" onClick=... Read More
What are the differences between GET and POST methods in form submitting, give the case where we can use GET and we can use POST methods?
Added on Sun, Jan 3, 2010
Anwser 1: When we submit a form, which has the GET method it displays pair of name/value used in the form at the address bar of the browser preceded by url. Post method doesn't display these values. Anwser 2: When... Read More
What Are the Special Characters You Need to Escape in Double-Quoted Stings?
Added on Tue, Jan 5, 2010
There are two special characters you need to escape in a double-quote string: the double quote (") and the back slash (). Here is a PHP script example of double-quoted strings: <?php echo "Hello world!"; echo "Tom said... Read More
How To Submit Values without a Form?
Added on Wed, Jan 6, 2010
If you know the values you want to submit, you can code the values in a hyper link at the end of the URL. The additional values provided at the end of a URL is called query string. There are two suggestions on how to use query strings... Read More
What is the difference between CHAR and VARCHAR data types?
Added on Sun, Jan 3, 2010
CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, "Hello!" will be stored as "Hello! " in CHAR(10) column. VARCHAR is a variable length... Read More
What are the differences between require and include, include_once?
Added on Sun, Jan 3, 2010
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... Read More
When are you supposed to use endif to end the conditional statement?
Added on Sun, Jan 3, 2010
When the original if was followed by : and then the code block without braces. Read More
How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?
Added on Sun, Jan 3, 2010
We can use the preg_match() function with "/.*@(.*)$/" as the regular expression pattern. For example: preg_match("/.*@(.*)$/","http://info@abc.com",$data); echo $data[1]; Read More
What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
Added on Mon, Jan 4, 2010
Answer: There is at least 3 ways to logon to a remote server: Use ssh or telnet if you concern with security You can also use rlogin to logon to a remote server. Read More
What is the maximum size of a file that can be uploaded using php and how can we change this?
Added on Mon, Jan 4, 2010
Answer: You can change maximum size of a file set upload_max_filesize variable in php.ini file Read More
What's Wrong with "while ($c=fgetc($f)) {}"?
Added on Tue, Jan 5, 2010
If you are using "while ($c=fgetc($f)) {}" to loop through each character in a file, the loop may end in the middle of the file when there is a "0" character, because PHP treats "0" as Boolean false. To properly loop to the end of the... Read More
How To Set a Persistent Cookie?
Added on Wed, Jan 6, 2010
If you want to set a persistent cookie, you can use the setcookie() function with an extra parameter to specify its expiration time. To follow sample script sets 2 persistent cookies to be expired within 7 days: setcookie(... Read More
How To Perform Key Word Search in Tables?
Added on Wed, Jan 6, 2010
The simplest way to perform key word search is to use the SELECT statement with a LIKE operator in the WHERE clause. The LIKE operator allows you to match a text field with a keyword pattern specified as '%keyword%', where (%)... Read More
What is the difference between include and require?
Added on Wed, Jan 6, 2010
If you require a file and it cannot be found, the script will terminate with a fatal error. If you use include then you will get an error but the script will continue to execute. Therefore when the information you wish to... Read More
Write a simple program to get a row of information from a database?
Added on Wed, Jan 6, 2010
$myrow = mysql_query("SELECT name,email FROM visitors ORDER by name LIMIT 1"); $data = mysql_fetch_row($myrow); $name = $data[0]; $email = $data[1]; echo "A row from the database is name $name and email $email"; ... Read More
How do you match the character ^ at the beginning of the string?
Added on Wed, Jan 6, 2010
We all know that PHP skills are in demand, and that's part of the reason why we learn and use PHP right? However, before getting that coveted job, there is the small matter of the interview to get through. Here we... Read More
So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?
Added on Wed, Jan 6, 2010
Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32- bit value in the database instead of the 160-bit value... Read More
What is meant by PEAR in php?
Added on Sun, Jan 3, 2010
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... Read More
What Is a Persistent Cookie?
Added on Sun, Jan 3, 2010
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... Read More
What does a special set of tags do in PHP?
Added on Sun, Jan 3, 2010
What does a special set of tags <?= and ?> do in PHP? The output is displayed directly to the browser. Read More
How do you define a constant?
Added on Sun, Jan 3, 2010
Via define() directive, like define ("MYCONSTANT", 100); Read More
What is meant by urlencode and urldecode?
Added on Sun, Jan 3, 2010
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... Read More
How To Get the Uploaded File Information in the Receiving Script?
Added on Sun, Jan 3, 2010
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... Read More
What is the difference between mysql_fetch_object and mysql_fetch_array?
Added on Sun, Jan 3, 2010
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array Read More
How can I execute a PHP script using command line?
Added on Sun, Jan 3, 2010
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... Read More
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
Added on Sun, Jan 3, 2010
PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems. Read More
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
Added on Sun, Jan 3, 2010
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. Read More
WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?
Added on Sun, Jan 3, 2010
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. Read More
How can we send mail using JavaScript?
Added on Sun, Jan 3, 2010
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) { ... Read More
What is the functionality of the function strstr and stristr?
Added on Sun, Jan 3, 2010
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... Read More
What is the difference between ereg_replace() and eregi_replace()?
Added on Sun, Jan 3, 2010
eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters. Read More
What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
Added on Sun, Jan 3, 2010
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... Read More
Write a query for the following question
Added on Sun, Jan 3, 2010
The table tbl_sites contains the following data: --------------------------------------- Userid sitename country --------------------------------------- 1 sureshbabu indian 2 PHPprogrammer andhra 3 PHP.net usa 4... Read More
What are the differences between DROP a table and TRUNCATE a table?
Added on Sun, Jan 3, 2010
DROP TABLE table_name - This will delete the table and its data. TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition. Read More
What’s the special meaning of __sleep and __wakeup?
Added on Sun, Jan 3, 2010
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them. Read More
How can we submit a form without a submit button?
Added on Sun, Jan 3, 2010
If you don't want to use the Submit button to submit a form, you can use normal hyper links to submit a form. But you need to use some JavaScript code in the URL of the link. For example: <a href="javascript: document... Read More
Would you initialize your strings with single quotes or double quotes?
Added on Sun, Jan 3, 2010
Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution. Read More
What is the difference between the functions unlink and unset?
Added on Sun, Jan 3, 2010
unlink() is a function for file system handling. It will simply delete the file in context. unset() is a function for variable management. It will make a variable undefined. Read More
How come the code works, but doesn’t for two-dimensional array of mine?
Added on Sun, Jan 3, 2010
Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked. Read More
How can we create a database using PHP and mysql?
Added on Sun, Jan 3, 2010
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database. Read More
How many ways we can retrieve the date in result set of mysql using php?
Added on Sun, Jan 3, 2010
As individual objects so single record or as a set or arrays. Read More
What’s the output of the ucwords function in this example?
Added on Sun, Jan 3, 2010
$formatted = ucwords("FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS"); print $formatted; What will be printed is FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS. ucwords() makes every first letter of every word capital, but it... Read More
What’s the difference between htmlentities() and htmlspecialchars()?
Added on Sun, Jan 3, 2010
htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML. Read More
How can we extract string "abc.com" from a string "mailto:info@abc.com?subject=Feedback" using regular expression of PHP?
Added on Sun, Jan 3, 2010
$text = "mailto:info@abc.com?subject=Feedback"; preg_match('|.*@([^?]*)|', $text, $output); echo $output[1]; Note that the second index of $output, $output[1], gives the match,... Read More
So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?
Added on Sun, Jan 3, 2010
Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to... Read More
How can we know the count/number of elements of an array?
Added on Sun, Jan 3, 2010
2 ways: a) sizeof($array) - This function is an alias of count() b) count($urarray) - This function returns the number of elements in an array. Interestingly if you just pass a simple var instead of an array, count() will return... Read More
Explain the ternary conditional operator in PHP?
Added on Sun, Jan 3, 2010
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed. Read More
How can we get the browser properties using php?
Added on Mon, Jan 4, 2010
Answer: <?php echo $_SERVER['HTTP_USER_AGENT'] . "
"; $browser = get_browser(null, true); print_r($browser); ?> Read More
How To Join Multiple Strings into a Single String?
Added on Tue, Jan 5, 2010
If you multiple strings stored in an array, you can join them together into a single string with a given delimiter by using the implode() function. Here is a PHP script on how to use implode(): <?php $date = array('01&... Read More
How Cookies Are Transported from Servers to Browsers?
Added on Wed, Jan 6, 2010
Cookies are transported from a Web server to a Web browser in the header area of the HTTP response message. Each cookie will be included in a separate "Set-Cookie:" header line in the following format: Set-Cookie: name=value;... Read More
How Many Cookies Can You Set?
Added on Wed, Jan 6, 2010
How many cookies can you set in your PHP page? The answer is depending what is the Web browser your visitor is using. Each browser has its own limit: Internet Explorere (IE): 20 Mozilla FireFox: 50 If you want to test... Read More
How To Write the FORM Tag Correctly for Uploading Files?
Added on Wed, Jan 6, 2010
When users clicks the submit button, files specified in the <INPUT TYPE=FILE...> will be transferred from the browser to the Web server. This transferring (uploading) process is controlled by a properly written <FORM...> tag... Read More
How To Create a Table To Store Files?
Added on Wed, Jan 6, 2010
If you using MySQL database and want to store files in database, you need to create BLOB columns, which can holds up to 65,535 characters. Here is a sample script that creates a table with a BLOB column to be used to store uploaded... Read More
How To Uploaded Files to a Table?
Added on Wed, Jan 6, 2010
To store uploaded files to MySQL database, you can use the normal SELECT statement as shown in the modified processing_uploaded_files.php listed below: <?php $con = mysql_connect("localhost", "", ""); ... Read More
How do you access data submitted through GET or POST from a form?
Added on Wed, Jan 6, 2010
To access data use $_GET and $_POST respectively. For instance if a form is submitted with a field named 'email' through post, then this becomes available as $_POST[email]. With GET, the information is posted in... Read More
What is the difference between $message and $$message?
Added on Sun, Jan 3, 2010
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... Read More
How do you pass a variable by value?
Added on Sun, Jan 3, 2010
Just like in C++, put an ampersand in front of it, like $a = &$b Read More
How To Protect Special Characters in Query String?
Added on Sun, Jan 3, 2010
If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode(): <?php print("<html>")... Read More
For printing out strings, there are echo, print and printf. Explain the differences.
Added on Sun, Jan 3, 2010
echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it... Read More
How can we destroy the session, how can we unset the variable of a session?
Added on Sun, Jan 3, 2010
session_unregister() - Unregister a global variable from the current session session_unset() - Free all session variables Read More
How can I load data from a text file into a table?
Added on Sun, Jan 3, 2010
The MySQL provides a LOAD DATA INFILE command. You can load data from a file. Great tool but you need to make sure that: a) Data must be delimited b) Data fields must match table columns correctly Read More
List out different arguments in PHP header function?
Added on Sun, Jan 3, 2010
void header ( string string [, bool replace [, int http_response_code]]) Read More
What is the difference between Reply-to and Return-path in the headers of a mail function?
Added on Sun, Jan 3, 2010
Reply-to: Reply-to is where to delivery the reply of the mail. Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification. Read More
Explain about Type Juggling in php?
Added on Sun, Jan 3, 2010
PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var... Read More
What changes I have to done in php.ini file for file uploading?
Added on Mon, Jan 4, 2010
Answer: Make the following Line uncomment like: ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ... Read More
Create a PHP web script with the following attributes: on start, three HTML form elements are shown:
Added on Mon, Jan 4, 2010
Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the... Read More
What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?
Added on Mon, Jan 4, 2010
Answer: 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 `... Read More
How Many Escape Sequences Are Recognized in Double-Quoted Strings?
Added on Tue, Jan 5, 2010
There are 12 escape sequences you can use in double-quoted strings: - Represents the back slash character. " - Represents the double quote character. $ - Represents the dollar sign. ... Read More
How To Split a String into an Array of Substring?
Added on Tue, Jan 5, 2010
There are two functions you can use to split a string into an Array of Substring: explode(substring, string) - Splitting a string based on a substring. Faster than split(). split(pattern, string) - Splitting a string... Read More
How To Read a File in Binary Mode?
Added on Tue, Jan 5, 2010
If you have a file that stores binary data, like an executable program or picture file, you need to read the file in binary mode to ensure that none of the data gets modified during the reading process. You need to: Open the file... Read More
How To Support Multiple-Page Forms?
Added on Wed, Jan 6, 2010
If you have a long form with a lots of fields, you may want to divide the fields into multiple groups and present multiple pages with one group of fields on one page. This makes the a long form more user-friendly. However, this requires... Read More
How To Send a Cookie to the Browser?
Added on Wed, Jan 6, 2010
If you want to sent a cookie to the browser when it comes to request your PHP page, you can use the setcookie( ) function. Note that you should call setcookie() function before any output statements. The following script shows you how... Read More
In Which Does File FireFox Store Persistent Cookies?
Added on Wed, Jan 6, 2010
If you change FireFox to keep cookies "until they expire", FireFox will store persistent cookies from all Web servers in a single file at: Documents and Settings$userApplication DataMozilla FirefoxProfilesxby7vgys.defaultcookie.txt. ... Read More
How To Set session.gc_maxlifetime Properly?
Added on Wed, Jan 6, 2010
As you know that session.gc_maxlifetime is the session value timeout period. You should set this value based on the usage pattern of your visitors. Here are some suggestions: # Set it to 20 minutes for a normal Web site: session... Read More
How do I find out the number of parameters passed into function?
Added on Wed, Jan 6, 2010
func_num_args() function returns the number of parameters passed in. Read More
What is the difference between characters 23 and x23?
Added on Wed, Jan 6, 2010
The first one is octal 23, the second is hex 23. Read More
What are the different functions in sorting an array?
Added on Sun, Jan 3, 2010
Sorting functions in PHP: asort() arsort() ksort() krsort() uksort() sort() natsort() rsort() Read More
How many ways we can pass the variable through the navigation between the pages?
Added on Sun, Jan 3, 2010
At least 3 ways: 1. Put the variable into session in the first page, and get it back from session in the next page. 2. Put the variable into cookie in the first page, and get it back from the cookie in the next page. 3.... Read More
What is the maximum length of a table name, a database name, or a field name in MySQL?
Added on Sun, Jan 3, 2010
Database name: 64 characters Table name: 64 characters Column name: 64 characters Read More
How can we find the number of rows in a table using MySQL?
Added on Sun, Jan 3, 2010
Use this for MySQL SELECT COUNT(*) FROM table_name; Read More
What’s the difference between md5(), crc32() and sha1() crypto on PHP?
Added on Sun, Jan 3, 2010
The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions. Read More
How can we find the number of rows in a result set using PHP?
Added on Sun, Jan 3, 2010
Here is how can you find the number of rows in a result set in PHP: $result = mysql_query($any_valid_sql, $database_link); $num_rows = mysql_num_rows($result); echo "$num_rows rows found"; Read More
Give the syntax of GRANT commands?
Added on Sun, Jan 3, 2010
The generic syntax for GRANT is as following GRANT [rights] on [database] TO [username@hostname] IDENTIFIED BY [password] Now rights can be: a) ALL privilages b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and... Read More
Give the syntax of REVOKE commands?
Added on Sun, Jan 3, 2010
The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privilages b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc. We can... Read More
What is the functionality of MD5 function in PHP?
Added on Sun, Jan 3, 2010
string md5(string) It calculates the MD5 hash of a string. The hash is a 32-character hexadecimal number. Read More
How can we change the name of a column of a table?
Added on Sun, Jan 3, 2010
This will change the name of column: ALTER TABLE table_name CHANGE old_colm_name new_colm_name Read More
How can we change the data type of a column of a table?
Added on Sun, Jan 3, 2010
This will change the data type of a column: ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type] Read More
What is the difference between GROUP BY and ORDER BY in SQL?
Added on Sun, Jan 3, 2010
To sort a result, use an ORDER BY clause. The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive, and then use this temporary... Read More
How can we know that a session is started or not?
Added on Sun, Jan 3, 2010
A session starts by session_start() function. This session_start() is always declared in header portion. it always declares first. then we write session_register(). Read More
What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
Added on Sun, Jan 3, 2010
Answer 1: mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array. mysql_fetch_object() -> Fetch a result row as an object. mysql_fetch_row() -> Fetch a result set as a regular... Read More
If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?
Added on Sun, Jan 3, 2010
Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser. Read More
What are the MySQL database files stored in system ?
Added on Sun, Jan 3, 2010
Data is stored in name.myd Table structure is stored in name.frm Index is stored in name.myi Read More
What is the difference between PHP4 and PHP5?
Added on Sun, Jan 3, 2010
PHP4 cannot support oops concepts and Zend engine 1 is used. PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and SQLLite will is increased in PHP5. Read More
Can we use include(abc.PHP) two times in a PHP page makeit.PHP”?
Added on Sun, Jan 3, 2010
Yes we can include that many times we want, but here are some things to make sure of: (including abc.PHP, the file names are case-sensitive) there shouldn't be any duplicate function names, means there... Read More
How can we encrypt and decrypt a data presented in a table using MySQL?
Added on Sun, Jan 3, 2010
You can use functions: AES_ENCRYPT() and AES_DECRYPT() like: AES_ENCRYPT(str, key_str) AES_DECRYPT(crypt_str, key_str) Read More
How can I retrieve values from one database server and store them in other database server using PHP?
Added on Sun, Jan 3, 2010
For this purpose, you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database. Read More
IN HOW MANY WAYS WE CAN RETRIEVE DATA IN THE RESULT SET OF MYSQL USING PHP?
Added on Sun, Jan 3, 2010
mysql_fetch_array - Fetch a result row as an associative array, a numeric array, or both mysql_fetch_assoc - Fetch a result row as an associative array mysql_fetch_object - Fetch a result row as an object mysql_fetch_row —... Read More
What are the functions for IMAP?
Added on Sun, Jan 3, 2010
imap_body - Read the message body imap_check - Check current mailbox imap_delete - Mark a message for deletion from current mailbox imap_mail - Send an email message Read More
What is the difference between htmlentities() and htmlspecialchars()?
Added on Sun, Jan 3, 2010
htmlspecialchars() - Convert some special characters to HTML entities (Only the most widely used) htmlentities() - Convert ALL special characters to HTML entities Read More
What is the functionality of the function htmlentities?
Added on Sun, Jan 3, 2010
htmlentities() - Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated... Read More
How can we get the properties (size, type, width, height) of an image using php image functions?
Added on Sun, Jan 3, 2010
To know the image size use getimagesize() function To know the image width use imagesx() function To know the image height use imagesy() function Read More
How can we increase the execution time of a php script?
Added on Sun, Jan 3, 2010
By the use of void set_time_limit(int seconds) Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time... Read More
HOW CAN WE TAKE A BACKUP OF A MYSQL TABLE AND HOW CAN WE RESTORE IT?
Added on Sun, Jan 3, 2010
Answer 1: Create a full backup of your database: shell> mysqldump tab=/path/to/some/dir opt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir The full backup file is just a set of SQL statements, so restoring it... Read More
How to set cookies?
Added on Sun, Jan 3, 2010
setcookie('variable','value','time') ; variable - name of the cookie variable value - value of the cookie variable time - expiry time Example: setcookie('Test',$i,time()+3600); ... Read More
How to reset/destroy a cookie
Added on Sun, Jan 3, 2010
Reset a cookie by specifying expire time in the past: Example: setcookie('Test',$i,time()-3600); // already expired time Reset a cookie by specifying its name only Example: setcookie('Test'); Read More
WHAT TYPES OF IMAGES THAT PHP SUPPORTS?
Added on Sun, Jan 3, 2010
Using imagetypes() function to find out what types of images are supported in your PHP engine. imagetypes() - Returns the image types supported. This function returns a bit-field corresponding to the image formats... Read More
How can I know that a variable is a number or not using a JavaScript?
Added on Sun, Jan 3, 2010
Answer 1: bool is_numeric( mixed var) Returns TRUE if var is a number or a numeric string, FALSE otherwise. Answer 2: Definition and Usage The isNaN() function is used to check if a value is not a number. Syntax ... Read More
How can we submit from without a submit button?
Added on Sun, Jan 3, 2010
Trigger the JavaScript code on any event ( like onSelect of drop down list box, onfocus, etc ) document.myform.submit(); This will submit the form. Read More
What are the current versions of Apache, PHP, and MySQL?
Added on Sun, Jan 3, 2010
PHP: PHP 5.1.2 MySQL: MySQL 5.1 Apache: Apache 2.1 Read More
What are the features and advantages of OBJECT ORIENTED PROGRAMMING?
Added on Sun, Jan 3, 2010
One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real... Read More
What is the use of friend function?
Added on Sun, Jan 3, 2010
Friend functions Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of... Read More
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
Added on Sun, Jan 3, 2010
You can change maximum size of a file set upload_max_filesize variable in php.ini file Read More
What is maximum size of a database in mysql?
Added on Sun, Jan 3, 2010
If the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint. The efficiency of the operating system in handling large numbers of files in a directory can place a... Read More
Explain normalization concept?
Added on Sun, Jan 3, 2010
The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal... Read More
What’s the difference between accessing a class method via -> and via ::?
Added on Sun, Jan 3, 2010
:: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization. Read More
What are the advantages and disadvantages of CASCADE STYLE SHEETS?
Added on Sun, Jan 3, 2010
External Style Sheets Advantages Can control styles for multiple documents at once Classes can be created for use on multiple HTML element types in many documents Selector and grouping methods can be used to apply styles under... Read More
What type of inheritance that php supports?
Added on Sun, Jan 3, 2010
In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'. Read More
How can increase the performance of MySQL select query?
Added on Sun, Jan 3, 2010
We can use LIMIT to stop MySql for further search in table after we have received our required no. of records, also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables. Read More
When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?
Added on Sun, Jan 3, 2010
When you use the metatag in the header section at the beginning of an HTML Web page, the Web page may still be cached in the Temporary Internet Files folder. A page that Internet Explorer is browsing is not cached until half of the... Read More
What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?
Added on Sun, Jan 3, 2010
There is at least 3 ways to logon to a remote server: Use ssh or telnet if you concern with security You can also use rlogin to logon to a remote server. Read More
How can I use the COM components in php?
Added on Sun, Jan 3, 2010
The COM class provides a framework to integrate (D)COM components into your PHP scripts. string COM::COM( string module_name [, string server_name [, int codepage]]) - COM class constructor. ... Read More
What is the default session time in php and how can I change it?
Added on Sun, Jan 3, 2010
The default session time in php is until closing of browser Read More
What changes I have to do in php.ini file for file uploading?
Added on Sun, Jan 3, 2010
Make the following line uncomment like: ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). upload_tmp_dir = C:apache2triad emp ... Read More
How can I set a cron and how can I execute it in Unix, Linux, and windows?
Added on Sun, Jan 3, 2010
Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it's called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word... Read More
Steps for the payment gateway processing?
Added on Sun, Jan 3, 2010
An online payment gateway is the interface between your merchant account and your Web site. The online payment gateway allows you to immediately verify credit card transactions and authorize funds on a customer's credit card... Read More
How many ways I can redirect a PHP page?
Added on Sun, Jan 3, 2010
Here are the possible ways of php page redirection. 1. Using Java script: '; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } ... Read More
What type of headers have to be added in the mail function to attach a file?
Added on Sun, Jan 3, 2010
$boundary = '--' . md5( uniqid ( rand() ) ); $headers = "From: "Me"
"; $headers .= "MIME-Version: 1.0
"; $headers .= "Content-Type: multipart/mixed; boundary="$boundary""; Read More
How to store the uploaded file to the final location?
Added on Sun, Jan 3, 2010
move_uploaded_file ( string filename, string destination) This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If... Read More
How can I embed a java programme in php file and what changes have to be done in php.ini file?
Added on Sun, Jan 3, 2010
There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment, which is the more stable and efficient solution, or integrate Java support into PHP. The former is provided by a SAPI... Read More
How To Turn On the Session Support?
Added on Sun, Jan 3, 2010
The session support can be turned on automatically at the site level, or manually in each PHP page script: Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini. Turning on session... Read More
What’s the difference between include and require?
Added on Sun, Jan 3, 2010
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue... Read More
How To Read the Entire File into a Single String?
Added on Sun, Jan 3, 2010
If you have a file, and you want to read the entire file into a single string, you can use the file_get_contents() function. It opens the specified file, reads all characters in the file, and returns them in a single string. Here is a... Read More
How can I find what type of images that the php version supports?
Added on Sun, Jan 3, 2010
Using Imagetypes() function we can know Usage: <?php if (imagetypes() & IMG_PNG) { echo "PNG Support is enabled"; } Read More
How can I get the only name of the current executing file?
Added on Sun, Jan 3, 2010
<?php $curfilename = __FILE__; //current file name with full path $pieces = explode("", $curfilename); $onlyfilenamewithext = $pieces[count($pieces)-1]; //current file name with extension only $temp =... Read More
What is the difference between using copy() and move() function in php file uploading?
Added on Mon, Jan 4, 2010
copy ( string source, string dest) Makes a copy of the file source to dest. Returns TRUE on success or FALSE on failure. Usage: <?php if (!copy($file, $file.'.bak')) { echo "failed to copy ... Read More
What are the differences between include() and include_once() functions?
Added on Mon, Jan 4, 2010
Answer: include_once() will use the specified file only once. include and require will use the specified file as many time we want. If include_once() is used before with same name, it can not done again Read More
What are the differences between php3 and php4 versions?
Added on Mon, Jan 4, 2010
Answer: As has already been mentioned by many PHP4 has native support for sessions and the much touted XML. While this makes PHP a competitor in the Application server languages arena, there is another core aspect to... Read More
What is the difference between <?php ?> and <? ?> And which can be preferable?
Added on Mon, Jan 4, 2010
Answer: If functionality is same but <? Is the short tag of <?php. Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers,... Read More
How many ways I can register the variables into session?
Added on Mon, Jan 4, 2010
Answer: session_register(); $_SESSION[]; $HTTP_SESSION_VARS[]; Read More
What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
Added on Mon, Jan 4, 2010
Answer: mysql_fetch_array -- Fetch a result row as an associative array, a numeric array, or both. mysql_fetch_object ( resource result ) Returns an object with properties that correspond to the fetched row and... Read More
How would you backup and restore a big MySQL database? What are the advantages of the approach which you have taken over the others?
Added on Mon, Jan 4, 2010
Use the mysqldump command. If you have Telnet/SSH access to your MySQL server, log in and issue the following command for each database you want to back up: shell> mysqldump -u user -ppassword --opt -full... Read More
A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?
Added on Mon, Jan 4, 2010
Answer: In general, when you want to make a slow SELECT … WHERE query faster, the first thing to check is whether you can add an index. All references between different tables should usually be done with indexes.... Read More
Please give a regular _expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example:
Added on Mon, Jan 4, 2010
The regular _expression should match the tag <A HREF="http://www.yoursite.com/" and give the URL ("http://www.yoursite.com/") as a return result. Tags should also be matched if they contain other attributes than the HREF... Read More
How can we change the name and data type of a column of a table?
Added on Mon, Jan 4, 2010
Answer: ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification] | CHANGE [COLUMN] old_col_name column_definition [FIRST|AFTER col_name] Read More
What are the advantages/disadvantages of mysql and php?
Added on Mon, Jan 4, 2010
Answer: Both of them are open source software (so free of cost), support cross platform. php is faster then ASP and JSP. Read More
Give the syntax of Grant and Revoke commands?
Added on Mon, Jan 4, 2010
The generic syntax for grant is as following > GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY [password] now rights can be a) All privilages b) combination of create, drop, select, insert... Read More
How many tables will create when we create table, what are they?
Added on Mon, Jan 4, 2010
Answer: 3 tables will create when we create table. They are The `.frm' file stores the table definition. The data file has a `.MYD' (MYData) extension. The index file has a `.MYI' (MYIndex) extension, ... Read More
How many values can the SET function of mysql takes?
Added on Mon, Jan 4, 2010
Answer: Mysql set can take zero or more values but at the maximum it can take 64 values Read More
How can we send mail-using _JavaScript?
Added on Mon, Jan 4, 2010
Answer: NO! JavaScript can't email a form! but, there are alternatives to send the form data to an email address. Try this: <form action="mailto:you@yourdmainhere.com" method="post" enctype="text/plain" ... Read More
How can I make a script that can be bilanguage (supports Eglish, German)?
Added on Mon, Jan 4, 2010
Answer : <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> You can change charset variable in above line in the script to support bilanguage. Read More
How can I know that a variable is a number or not using a _JavaScript?
Added on Mon, Jan 4, 2010
Answer: function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if... Read More
How can we optimize or increase the speed of a mysql select query?
Added on Mon, Jan 4, 2010
Answer: In general, when you want to make a slow SELECT … WHERE query faster, the first thing to check is whether you can add an index. All references between different tables should usually be done with indexes. You... Read More
How can we take a backup of a mysql table and how can we restore it.?
Added on Mon, Jan 4, 2010
Answer: Create a full backup of your database: shell> mysqldump --tab=/path/to/some/dir --opt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir The full backup file is just a set of SQL... Read More
How can we get the properties (size, type, width, height) of an image using php image functions?
Added on Mon, Jan 4, 2010
Answer: To know the Image type use exif_imagetype () function To know the Image size use getimagesize () function To know the image width use imagesx () function To know the image height use imagesy() function Read More
What is meant by urlencode and urldocode?
Added on Mon, Jan 4, 2010
Answer: 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... Read More
How can we convert the time zones using php?
Added on Mon, Jan 4, 2010
Answer: <? echo "Original Time: ". date("h:i:s")."
"; putenv("TZ=US/Eastern"); echo "New Time: ". date("h:i:s")."
"; ?> Read More
What are the differences between PROCEDURE ORIENTED LANGUAGES AND OBJECT ORIENTED LANGUAGES?
Added on Mon, Jan 4, 2010
Answer: Traditional programming has the following characteristics: Functions are written sequentially, so that a change in programming can affect any code that follows it. If a function is used multiple times in... Read More
How can we encrypt the username and password using php?
Added on Mon, Jan 4, 2010
Answer: You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password"); We can encode data using base64_encode($string) and can decode using base64_decode($string); Read More
Suppose your ZEND engine supports the mode <? ?> Then how can u configure your php ZEND engine to support <?php ?> mode ?
Added on Mon, Jan 4, 2010
Answer: If you change the line: short_open_tag = off in php.ini file. Then your php ZEND engine support only <?php ?> mode. Read More
What Are the Special Characters You Need to Escape in Single-Quoted Stings?
Added on Tue, Jan 5, 2010
There are two special characters you need to escape in a single-quote string: the single quote (') and the back slash (). Here is a PHP script example of single-quoted strings: <?php echo 'Hello world!'; ... Read More
How Many Escape Sequences Are Recognized in Single-Quoted Strings?
Added on Tue, Jan 5, 2010
There are 2 escape sequences you can use in single-quoted strings: - Represents the back slash character. ' - Represents the single quote character. Read More
How To Include Variables in Double-Quoted Strings?
Added on Tue, Jan 5, 2010
Variables included in double-quoted strings will be interpolated. Their values will be concatenated into the enclosing strings. For example, two statements in the following PHP script will print out the same string: <?php ... Read More
How Many Ways to Include Array Elements in Double-Quoted Strings?
Added on Tue, Jan 5, 2010
There are 2 formats to include array elements in double-quoted strings: "part 1 $array[key] part 2" - This is called simple format. In this format, you can not specify the element key in quotes. "part 1 {$array['... Read More
How To Access a Specific Character in a String?
Added on Tue, Jan 5, 2010
Any character in a string can be accessed by a special string element expression: $string{index} - The index is the position of the character counted from left and starting from 0. Here is a PHP script example: ... Read More
How To Assigning a New Character in a String?
Added on Tue, Jan 5, 2010
The string element expression, $string{index}, can also be used at the left side of an assignment statement. This allows you to assign a new character to any position in a string. Here is a PHP script example: <?php ... Read More
How to Concatenate Two Strings Together?
Added on Tue, Jan 5, 2010
You can use the string concatenation operator (.) to join two strings into one. Here is a PHP script example of string concatenation: <?php echo 'Hello ' . "world!... Read More
How To Convert Strings to Numbers?
Added on Tue, Jan 5, 2010
In a numeric context, PHP will automatically convert any string to a numeric value. Strings will be converted into two types of numeric values, double floating number and integer, based on the following rules: The value is given... Read More
How To Get the Number of Characters in a String?
Added on Tue, Jan 5, 2010
You can use the "strlen()" function to get the number of characters in a string. Here is a PHP script example of strlen(): <?php print(strlen('It's Friday!')); ?> This script will print: 12 ... Read More
How To Remove White Spaces from the Beginning and/or the End of a String?
Added on Tue, Jan 5, 2010
There are 4 PHP functions you can use remove white space characters from the beginning and/or the end of a string: trim() - Remove white space characters from the beginning and the end of a string. ltrim() - Remove... Read More
How To Remove the New Line Character from the End of a Text Line?
Added on Tue, Jan 5, 2010
If you are using fgets() to read a line from a text file, you may want to use the chop() function to remove the new line character from the end of the line as shown in this PHP script: <?php $handle = fopen("/tmp/inputfile... Read More
How To Remove Leading and Trailing Spaces from User Input Values?
Added on Tue, Jan 5, 2010
If you are taking input values from users with a Web form, users may enter extra spaces at the beginning and/or the end of the input values. You should always use the trim() function to remove those extra spaces as shown in this PHP... Read More
How to Find a Substring from a Given String?
Added on Tue, Jan 5, 2010
To find a substring in a given string, you can use the strpos() function. If you call strpos($haystack, $needle), it will try to find the position of the first occurrence of the $needle string in the $haystack string. If found, it will... Read More
How To Take a Substring from a Given String?
Added on Tue, Jan 5, 2010
If you know the position of a substring in a given string, you can take the substring out by the substr() function. Here is a PHP script on how to use substr(): <?php $string = "beginning"; print("Position counted from... Read More
How To Replace a Substring in a Given String?
Added on Tue, Jan 5, 2010
If you know the position of a substring in a given string, you can replace that substring by another string by using the substr_replace() function. Here is a PHP script on how to use substr_replace(): <?php $string = "Warning... Read More
How To Reformat a Paragraph of Text?
Added on Tue, Jan 5, 2010
You can wordwrap() reformat a paragraph of text by wrapping lines with a fixed length. Here is a PHP script on how to use wordwrap(): <?php $string = "TRADING ON MARGIN POSES ADDITIONAL RISKS AND IS NOT SUITABLE FOR ALL ... Read More
How To Convert Strings to Upper or Lower Cases?
Added on Tue, Jan 5, 2010
Converting strings to upper or lower cases are easy. Just use strtoupper() or strtolower() functions. Here is a PHP script on how to use them: <?php $string = "PHP string functions are easy to use."; $lower = strtolower(... Read More
How To Convert the First Character to Upper Case?
Added on Tue, Jan 5, 2010
If you are processing an article, you may want to capitalize the first character of a sentence by using the ucfirst() function. You may also want to capitalize the first character of every words for the article title by using the... Read More
How To Compare Two Strings with strcmp()?
Added on Tue, Jan 5, 2010
PHP supports 3 string comparison operators, <, ==, and >, that generates Boolean values. But if you want to get an integer result by comparing two strings, you can the strcmp() function, which compares two strings based on... Read More
How To Convert Strings in Hex Format?
Added on Tue, Jan 5, 2010
If you want convert a string into hex format, you can use the bin2hex() function. Here is a PHP script on how to use bin2hex(): <?php $string = "Hello world!
"; print($string."
"); print(bin2hex($string)."
"); ?> ... Read More
How To Convert a Character to an ASCII Value?
Added on Tue, Jan 5, 2010
If you want to convert characters to ASCII values, you can use the ord() function, which takes the first charcter of the specified string, and returns its ASCII value in decimal format. ord() complements chr(). Here is a PHP script on... Read More
How To Split a String into Pieces?
Added on Tue, Jan 5, 2010
There are two functions you can use to split a string into pieces: explode(substring, string) - Splitting a string based on a substring. Faster than split(). split(pattern, string) - Splitting a string based on a... Read More
How To Apply UUEncode to a String?
Added on Tue, Jan 5, 2010
UUEncode (Unix-to-Unix Encoding) is a simple algorithm to convert a string of any characters into a string of printable characters. UUEncode is reversible. The reverse algorithm is called UUDecode. PHP offeres two functions for you to... Read More
How To Replace a Group of Characters by Another Group?
Added on Tue, Jan 5, 2010
While processing a string, you may want to replace a group of special characters with some other characters. For example, if you don't want to show user's email addresses in the original format to stop email spammer collecting... Read More
What Is an Array in PHP?
Added on Tue, Jan 5, 2010
An array in PHP is really an ordered map of pairs of keys and values. Comparing with Perl, an array in PHP is not like a normal array in Perl. An array in PHP is like an associate array in Perl. But an array in PHP can work like... Read More
How To Create an Array?
Added on Tue, Jan 5, 2010
You can create an array using the array() constructor. When calling array(), you can also initialize the array with pairs of keys and values. Here is a PHP script on how to use array(): <?php print("Empty array:... Read More
How Do You If a Key Is Defined in an Array?
Added on Tue, Jan 5, 2010
There are two functions can be used to test if a key is defined in an array or not: array_key_exists($key, $array) - Returns true if the $key is defined in $array. isset($array[$key]) - Returns true if the $key is... Read More
How To Find a Specific Value in an Array?
Added on Tue, Jan 5, 2010
There are two functions can be used to test if a value is defined in an array or not: array_search($value, $array) - Returns the first key of the matching value in the array, if found. Otherwise, it returns false. ... Read More
How To Get All the Keys Out of an Array?
Added on Tue, Jan 5, 2010
Function array_keys() returns a new array that contains all the keys of a given array. Here is a PHP script on how to use array_keys(): <?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed["Two... Read More
How To Get All the Values Out of an Array?
Added on Tue, Jan 5, 2010
F unction array_values() returns a new array that contains all the keys of a given array. Here is a PHP script on how to use array_values(): <?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed[... Read More
How To Sort an Array by Keys?
Added on Tue, Jan 5, 2010
Sorting an array by keys can be done by using the ksort() function. It will re-order all pairs of keys and values based on the alphanumeric order of the keys. Here is a PHP script on how to use ksort(): <?php $mixed = array()... Read More
How To Merge Values of Two Arrays into a Single Array?
Added on Tue, Jan 5, 2010
You can use the array_merge() function to merge two arrays into a single array. array_merge() appends all pairs of keys and values of the second array to the end of the first array. Here is a PHP script on how to use array_merge(): ... Read More
How To Use an Array as a Stack?
Added on Tue, Jan 5, 2010
A stack is a simple data structure that manages data elements following the first-in-last-out rule. You use the following two functions together to use an array as a stack: array_push($array, $value) - Pushes a new value to the... Read More
How To Randomly Retrieve a Value from an Array?
Added on Tue, Jan 5, 2010
If you have a list of favorite greeting messages, and want to randomly select one of them to be used in an email, you can use the array_rand() function. Here is a PHP example script: <?php $array = array("Hello!", "Hi!", ... Read More
How To Loop through an Array without Using "foreach"?
Added on Tue, Jan 5, 2010
PHP offers the following functions to allow you loop through an array without using the "foreach" statement: reset($array) - Moves the array internal pointer to the first value of the array and returns that value. end(... Read More
How To Pad an Array with the Same Value Multiple Times?
Added on Tue, Jan 5, 2010
If you want to add the same value multiple times to the end or beginning of an array, you can use the array_pad($array, $new_size, $value) function. If the second argument, $new_size, is positive, it will pad to the end of the array. If... Read More
How To Truncate an Array?
Added on Tue, Jan 5, 2010
If you want to remove a chunk of values from an array, you can use the array_splice($array, $offset, $length) function. $offset defines the starting position of the chunk to be removed. If $offset is positive, it is counted from the... Read More
How To Join Multiple Strings Stored in an Array into a Single String?
Added on Tue, Jan 5, 2010
If you multiple strings stored in an array, you can join them together into a single string with a given delimiter by using the implode() function. Here is a PHP script on how to use implode(): <?php $date = array('01&... Read More
How To Get the Minimum or Maximum Value of an Array?
Added on Tue, Jan 5, 2010
If you want to get the minimum or maximum value of an array, you can use the min() or max() function. Here is a PHP script on how to use min() and max(): <?php $array = array(5, 7, 6, 2, 1, 3, 4, 2); print("Minimum number:... Read More
How To Define a User Function?
Added on Tue, Jan 5, 2010
You can define a user function anywhere in a PHP script using the function statement like this: "function name() {...}". Here is a PHP script example on how to define a user function: <?php function msg() { print(... Read More
How To Invoke a User Function?
Added on Tue, Jan 5, 2010
You can invoke a function by entering the function name followed by a pair of parentheses. If needed, function arguments can be specified as a list of expressions enclosed in parentheses. Here is a PHP script example on how to invoke a... Read More
How To Return a Value Back to the Function Caller?
Added on Tue, Jan 5, 2010
You can return a value to the function caller by using the "return $value" statement. Execution control will be transferred to the caller immediately after the return statement. If there are other statements in the function after the... Read More
How Variables Are Passed Through Arguments?
Added on Tue, Jan 5, 2010
Like more of other programming languages, variables are passed through arguments by values, not by references. That means when a variable is passed as an argument, a copy of the value will be passed into the function. Modipickzyng that... Read More
Can You Define an Argument as a Reference Type?
Added on Tue, Jan 5, 2010
You can define an argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an argument as a reference type: <?php ... Read More
Can You Pass an Array into a Function?
Added on Tue, Jan 5, 2010
You can pass an array into a function in the same as a normal variable. No special syntax needed. Here is a PHP script on how to pass an array to a function: <?php function average($array) { $sum = array_sum($array)... Read More
How Arrays Are Passed Through Arguments?
Added on Tue, Jan 5, 2010
Like a normal variable, an array is passed through an argument by value, not by reference. That means when an array is passed as an argument, a copy of the array will be passed into the function. Modipickzyng that copy inside the... Read More
Can You Define an Array Argument as a Reference Type?
Added on Tue, Jan 5, 2010
You can define an array argument as a reference type in the function definition. This will automatically convert the calling arguments into references. Here is a PHP script on how to define an array argument as a reference type: ... Read More
How To Return an Array from a Function?
Added on Tue, Jan 5, 2010
You can return an array variable like a normal variable using the return statement. No special syntax needed. Here is a PHP script on how to return an array from a function: <?php function powerBall() { $array =... Read More
What Is the Scope of a Variable Defined in a Function?
Added on Tue, Jan 5, 2010
The scope of a local variable defined in a function is limited with that function. Once the function is ended, its local variables are also removed. So you can not access any local variable outside its defining function. Here is a PHP... Read More
What Is the Scope of a Variable Defined outside a Function?
Added on Tue, Jan 5, 2010
A variable defined outside any functions in main script body is called global variable. However, a global variable is not really accessible globally any in the script. The scope of global variable is limited to all statements outside... Read More
How Values Are Returned from Functions?
Added on Tue, Jan 5, 2010
If a value is returned from a function, it is returned by value, not by reference. That means that a copy of the value is return. Here is a PHP script on how values are returned from a function: <?php $favor = "vbulletin"... Read More
How To Return a Reference from a Function?
Added on Tue, Jan 5, 2010
To return a reference from a function, you need to: Add the reference operator "&" when defining the function. Add the reference operator "&" when invoking the function. Here is a PHP script on how... Read More
How To Specify Argument Default Values?
Added on Tue, Jan 5, 2010
If you want to allow the caller to skip an argument when calling a function, you can define the argument with a default value when defining the function. Adding a default value to an argument can be done like this "function name($arg... Read More
How To Define a Function with Any Number of Arguments?
Added on Tue, Jan 5, 2010
If you want to define a function with any number of arguments, you need to: Declare the function with no argument. Call func_num_args() in the function to get the number of the arguments. Call func_get_args() in... Read More
How To Read a Text File into an Array?
Added on Tue, Jan 5, 2010
If you have a text file with multiple lines, and you want to read those lines into an array, you can use the file() function. It opens the specified file, reads all the lines, puts each line as a value in an array, and returns the array... Read More
How To Open a File for Reading?
Added on Tue, Jan 5, 2010
If you want to open a file and read its contents piece by piece, you can use the fopen($fileName, "r") function. It opens the specified file, and returns a file handle. The second argument "r" tells PHP to open the file for reading.... Read More
How To Open a File for Writing?
Added on Tue, Jan 5, 2010
If you want to open a new file and write date to the file, you can use the fopen($fileName, "w") function. It creates the specified file, and returns a file handle. The second argument "w" tells PHP to open the file for writing. Once... Read More
How To Append New Data to the End of a File?
Added on Tue, Jan 5, 2010
If you have an existing file, and want to write more data to the end of the file, you can use the fopen($fileName, "a") function. It opens the specified file, moves the file pointer to the end of the file, and returns a file handle. The... Read More
How To Read One Line of Text from a File?
Added on Tue, Jan 5, 2010
If you have a text file with multiple lines, and you want to read those lines one line at a time, you can use the fgets() function. It reads the current line up to the "... Read More
How To Read One Character from a File?
Added on Tue, Jan 5, 2010
If you have a text file, and you want to read the file one character at a time, you can use the fgetc() function. It reads the current character, moves the file pointer to the next character, and returns the character as a string. If... Read More
How To Write a String to a File with a File Handle?
Added on Tue, Jan 5, 2010
If you have a file handle linked to a file opened for writing, and you want to write a string to the file, you can use the fwrite() function. It will write the string to the file where the file pointer is located, and moves the file... Read More
How To Read Data from Keyborad (Standard Input)?
Added on Tue, Jan 5, 2010
If you want to read data from the standard input, usually the keyboard, you can use the fopen("php://stdin") function. It creates a special file handle linking to the standard input, and returns the file handle. Once the standard input... Read More
How To Open Standard Output as a File Handle?
Added on Tue, Jan 5, 2010
If you want to open the standard output as a file handle yourself, you can use the fopen("php://stdout") function. It creates a special file handle linking to the standard output, and returns the file handle. Once the standard output is... Read More
How To Create a Directory?
Added on Tue, Jan 5, 2010
You can use the mkdir() function to create a directory. Here is a PHP script example on how to use mkdir(): <?php if (file_exists("/temp/download")) { print("Directory already exists.... Read More
How To Remove an Empty Directory?
Added on Tue, Jan 5, 2010
If you have an empty existing directory and you want to remove it, you can use the rmdir(). Here is a PHP script example on how to use rmdir(): <?php if (file_exists("/temp/download")) { rmdir("/temp/download"); ... Read More
How To Remove a File?
Added on Tue, Jan 5, 2010
If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink(): <?php if (file_exists("/temp/todo.txt")) { unlink("/temp/todo.txt"); print(... Read More
How To Copy a File?
Added on Tue, Jan 5, 2010
If you have a file and want to make a copy to create a new file, you can use the copy() function. Here is a PHP script example on how to use copy(): <?php unlink("/temp/myPing.exe"); copy("/windows/system32/ping.exe", "... Read More
How To Dump the Contents of a Directory into an Array?
Added on Tue, Jan 5, 2010
If you want to get the contents of a directory into an array, you can use the scandir() function. It gets a list of all the files and sub directories of the specified directory and returns the list as an array. The returning list also... Read More
How To Break a File Path Name into Parts?
Added on Tue, Jan 5, 2010
If you have a file name, and want to get different parts of the file name, you can use the pathinfo() function. It breaks the file name into 3 parts: directory name, file base name and file extension; and returns them in an array. Here... Read More
How To Create a Web Form?
Added on Tue, Jan 5, 2010
If you take input data from visitors on your Web site, you can create a Web form with input fields to allow visitors to fill in data and submit the data to your server for processing. A Web form can be created with the <FORM> tag... Read More
What Are Form Input HTML Tags?
Added on Tue, Jan 5, 2010
HTML tags that can be used in a form to collect input data are: <SUBMIT ...> - Displayed as a button allow users to submit the form. <INPUT TYPE=TEXT ...> - Displayed as an input field to take an input... Read More
How To Generate a Form?
Added on Tue, Jan 5, 2010
Generating a form seems to be easy. You can use PHP output statements to generate the required <FORM> tag and other input tags. But you should consider to organized your input fields in a table to make your form looks good on the... Read More
How To Retrieve the Submitted Form Data?
Added on Tue, Jan 5, 2010
The best way to retrieve the form data submitted by your visitor is to use the $_REQUEST array. The keys in this array will be the field names defined in form. The values in this array will be the values entered by your visitor in the... Read More
How To Avoid the Undefined Index Error?
Added on Tue, Jan 5, 2010
If you don't want your PHP page to give out errors as shown in the previous exercise, you should consider checking all expected input fields in $_REQUEST with the isset() function as shown in the example script below: <?php... Read More
How To List All Values of Submitted Fields?
Added on Tue, Jan 5, 2010
If you want list all values of submitted fields, you can write a simple loop to retrieve all entries in the $_REQUEST array. Below is an improved version of processing_forms.php to list all submited input values: <?php ... Read More
What Are the Input Values of SELECT Tags?
Added on Tue, Jan 5, 2010
SELECT tags are used in forms to provide dropdown lists. Entris in a dropdown list are defined by OPTION tags, which can provide input values in two ways: Implicit value - Provided as <OPTION>input_value</OPTION>... Read More
How To Specify Input Values for Checkboxes?
Added on Tue, Jan 5, 2010
Checkboxes can be used in a form for two situations: As a single switch - One <INPUT TYPE=CHECKBOX ...> tag, with no input value specified. When submitted with button pushed down, you will receive a value of ... Read More
How To Retrieve Input Values for Checkboxes Properly?
Added on Tue, Jan 5, 2010
If multiple input values are submitted with the same field name, like the case of a group of checkboxes, you should add ([]) to the end of the field name. This tells the PHP engine that multiple values are expected for this field.... Read More
How To Supply Default Values for Text Fields?
Added on Tue, Jan 5, 2010
If you want to provide a default value to a text field in your form, you need to pay attention to following notes: The default value should be provided in the 'VALUE=default_value' attribute in the <INPUT... Read More
How To Generate and Process a Form with the Same Script?
Added on Wed, Jan 6, 2010
In previous exercises, a Web form is generated by one script, and processed by another script. But you could write a single script to do both. You just need to remember to: Use same script name as the form generation script in... Read More
How To Retrieve the Original Query String?
Added on Wed, Jan 6, 2010
If you have coded some values in the URL without using the standard form GET format, you need to retrieve those values in the original query string in $_SERVER['QUERY_STRING']. The script below is an enhanced version of... Read More
What Is a Cookie?
Added on Wed, Jan 6, 2010
A cookie is a small amount of information sent by a Web server to a web browser and then sent back unchanged by the browser each time it accesses that server. HTTP cookies are used for authenticating, tracking, and maintaining specific... Read More
How To Receive a Cookie from the Browser?
Added on Wed, Jan 6, 2010
If you know that a cookie has been sent to the browser when it was visiting the server previously, you can check the built-in $_COOKIE array, which contains all cookies that were sent by the server previously. The script below shows you... Read More
How To Test Cookies on a Web Server?
Added on Wed, Jan 6, 2010
If you want to test cookies with a browser, you need to run a Web server locally, or have access to a Web server remotely. Then you can copy the following PHP cookie test page, setting_receiving_cookies.php, to the Web server: <... Read More
How To Remove a Cookie?
Added on Wed, Jan 6, 2010
Once a cookie is sent from the server to the browser, there is no direct way for the server to ask the browser to remove the cookie. But you can use the setcookie() function to send the same cookie to browser with a negative expiration... Read More
What Are Domain and Path Attributes for Cookies?
Added on Wed, Jan 6, 2010
Cookies can also be defined with two other attributes: Domain - A cookie attribute that defines the domain name of Web servers where this cookie is valid. Web browsers holding this cookie should not sent it back to any... Read More
How To Specify Domain and Path for a Cookie?
Added on Wed, Jan 6, 2010
If you want to specify domain and path for cookie, you can use the setcookie() function with two extra parameters. The sample PHP script below shows you how to set the domain and path attributes for temporary and persistent cookies: ... Read More
How Cookies Are Transported from Browsers to Servers?
Added on Wed, Jan 6, 2010
Cookies are transported from a Web browser to a Web server in the header area of the HTTP request message. Each cookie will be included in a separate "Cookie:" header line in the following format: GET / HTTP/1.1 Cookie: name1... Read More
How To Delete Cookie Files on Your Computer?
Added on Wed, Jan 6, 2010
A simple way to delete cookie files on your computer is to use the function offered by the IE browser. The following tutorial exercise shows you how to delete cookie files created by IE: Open IE (Internet Explorer) Go to... Read More
How View the Content of a Cookie File?
Added on Wed, Jan 6, 2010
Cookie files are normal text files. You can view them with any text editor. Follow the steps below to see what is in a cookie file created by your own PHP script. Copy the following sample script, setting_persistent_cookies.php,... Read More
How Does FireFox Manage Cookies?
Added on Wed, Jan 6, 2010
FireFox browser allows you to delete old cookies, and gives you options to keep persistent cookies in cookie files until they reach their expiration time. The following tutorial shows you how to manage cookies in FireFox: Run... Read More
How Large Can a Single Cookie Be?
Added on Wed, Jan 6, 2010
How large can a single cookie be? The answer is depending what is the Web browser your visitor is using. Each browser has its own limit: Internet Explorere (IE): about 3904 bytes Mozilla FireFox: about 3136 bytess If... Read More
How Are Cookies Encoded During Transportation?
Added on Wed, Jan 6, 2010
When cookies are transported from servers to browsers and from browsers back to servers, Cookies values are always encoded using the URL encoding standard to ensure that they are transported accurately. But you don't need to worry... Read More
How To Retrieve Values from the Current Session?
Added on Wed, Jan 6, 2010
If you know some values have been saved in the session by an other script requested by the same visitor, you can retrieve those values back by using the pre-defined associative array called $_SESSION. The following PHP script shows you... Read More
What Is a Session ID?
Added on Wed, Jan 6, 2010
A session ID is an identification string of a session. Since there might be multiple visitors coming to your Web site at the same time, the PHP engine needs to maintain multiple sessions concurrently. Session IDs are created and... Read More
How To Retrieve the Session ID of the Current Session?
Added on Wed, Jan 6, 2010
Normally, you don't need to know the session ID of the current session. But if you are interested to know the session ID created by the PHP engine, there are two ways to get it: Calling session() function. It will return the... Read More
What Are the Options to Transfer Session IDs?
Added on Wed, Jan 6, 2010
Once a new session is created, its session ID must be transferred to the client browser and included in the next client request, so that the PHP engine can find the same session created by the same visitor. The PHP engine has two... Read More
How Session IDs Are Transferred on Your Web Server?
Added on Wed, Jan 6, 2010
As you know there are two options the PHP engine can use to transfer session IDs to the client browsers. But how to do know which option is your PHP engine is using? The PHP sample script will help you to find out: <?php ... Read More
How To Force the PHP Engine to Use Cookies to Transfer Session IDs?
Added on Wed, Jan 6, 2010
If you want to force your PHP engine to use cookies to transfer session IDs instead of URL parameters, you can open the PHP configuration file, php.ini, and make the following changes: session.use_cookies = 1 session... Read More
Is It More Secure to Use Cookies to Transfer Session IDs?
Added on Wed, Jan 6, 2010
Is it more secure to use cookies to transfer session IDs? The answer is yes, because attacking your Web site using URL parameters is much easier than using cookies. So if you are the system administrator of your Web server, you... Read More
Where Are the Session Values Stored?
Added on Wed, Jan 6, 2010
When a value is saved into the current session by one PHP page, the PHP engine must stored this value somewhere on Web server, so that the PHP engine can retrieve it back when same visitor comes back to request another PHP page. ... Read More
What Is the Timeout Period on Session Values?
Added on Wed, Jan 6, 2010
The PHP engine has no direct settings on session timeout period. But it has a session garbage collection mechanism that you can set to remove those special files containing session values. There are 3 settings you can use to define the... Read More
How To Test the Session Garbage Collection Process?
Added on Wed, Jan 6, 2010
In order to test the session garbage collection process, you need to change the settings to expire session variables in 10 seconds and run the process on every request: session.gc_probability = 1 session.gc_divisor ... Read More
How To Set session.gc_divisor Properly?
Added on Wed, Jan 6, 2010
As you know that session.gc_divisor is the frequency of when the session garbage collection process will be executed. You should set this value based on the income request traffic. Here are some suggestions: # Set it to 10, if... Read More
How To Remove Values Saved in the Current Session?
Added on Wed, Jan 6, 2010
If you want to remove values saved in the current session, you should use the unset() function on those saved values in $_SESSION, or use array() to empty $_SESSION: unset($_SESSION['MyColor']) - Removes one value named... Read More
How To Tell If a Session Is New?
Added on Wed, Jan 6, 2010
There is not direct way to tell if a session is new or old. But you can design your site to have a required session value in all sessions. Then you can check the existence of this value in a session to determine if it is a new session... Read More
How To Close a Session Properly?
Added on Wed, Jan 6, 2010
Let's say you site requires users to login. When a logged in user clicks the logout button, you need to close the session associated with this user properly in 3 steps: Remove all session values with $_SESSION = array(). ... Read More
How To Install MySQL?
Added on Wed, Jan 6, 2010
MySQL is an open source database management system developed by MySQL AB, http://www.mysql.com. You can download a copy and install it on your local computer. Here is how you can do this: Go to http://dev.mysql... Read More
What Do You Need to Connect PHP to MySQL?
Added on Wed, Jan 6, 2010
If you want to access MySQL database server in your PHP script, you need to make sure that MySQL module is installed and turned on in your PHP engine. Check the PHP configuration file, php.ini, to make sure the extension=php_mysql.dll... Read More
How To Connect to MySQL from a PHP Script?
Added on Wed, Jan 6, 2010
If you want access the MySQL server, you must create a connection object first by calling the mysql_connect() function in the following format: $con = mysql_connect($server, $username, $password); If you are connecting to a... Read More
How To Create a Database?
Added on Wed, Jan 6, 2010
A database in a MySQL server is a logical container used to group tables and other data objects together as a unit. If you are a the administrator of the server, you can create and delete databases using the CREATE/DROP DATABASE... Read More
How To Select an Exiting Database?
Added on Wed, Jan 6, 2010
The first thing after you have created a connection object to the MySQL server is to select the database where your tables are locate, by using the mysql_select_db() function. If your MySQL server is offered by your Web hosting company,... Read More
How To Run a SQL Statement?
Added on Wed, Jan 6, 2010
You can run any types of SQL statements through the mysql_query() function. It takes the SQL statement as a string and returns different types of data depending on the SQL statement type and execution status: Returning FALSE, if... Read More
How To Get the Number of Rows Selected or Affected by a SQL Statement?
Added on Wed, Jan 6, 2010
There are two functions you can use the get the number of rows selected or affected by a SQL statement: mysql_num_rows($rs) - Returns the number of rows selected in a result set object returned from SELECT statement. ... Read More
How To Insert Data into a Table?
Added on Wed, Jan 6, 2010
If you want to insert a row of data into a table, you can use the INSERT INTO statement as shown in the following sample script: <?php include "mysql_connection.php"; $sql = "INSERT INTO... Read More
How To Insert Rows Based on SELECT Statements?
Added on Wed, Jan 6, 2010
If want to insert rows into a table based on data rows from other tables, you can use a sub-query inside the INSERT statement as shown in the following script example: <?php include "mysql_connection.php"; ... Read More
What Is a Result Set Object?
Added on Wed, Jan 6, 2010
A result set object is a logical representation of data rows returned by mysql_query() function on SELECT statements. Every result set object has an internal pointer used to identify the current row in the result set. Once you get a... Read More
How To Query Tables and Loop through the Returning Rows?
Added on Wed, Jan 6, 2010
The best way to query tables and loop through the returning rows is to run the SELECT statement with the catch the mysql_query() function, catch the returning object as a result set, and loop through the result with the... Read More
How To Update an Existing Rows in a Table?
Added on Wed, Jan 6, 2010
Updating existing rows in a table requires to run the UPDATE statement with a WHERE clause to identify the row. The following sample script updates one row with two new values: <?php include "mysql_connection.php"; ... Read More
How To Quote Text Values in SQL Statements?
Added on Wed, Jan 6, 2010
Text values in SQL statements should be quoted with single quotes ('). If the text value contains a single quote ('), it should be protected by replacing it with two single quotes (''). In SQL language syntax, two... Read More
How To Quote Date and Time Values in SQL Statements?
Added on Wed, Jan 6, 2010
If you want to provide date and time values in a SQL statement, you should write them in the format of "yyyy-mm-dd hh:mm:ss", and quoted with single quotes ('). The tutorial exercise below shows you two INSERT statements. The first... Read More
How To Query Multiple Tables Jointly?
Added on Wed, Jan 6, 2010
If you want to query information stored in multiple tables, you can use the SELECT statement with a WHERE condition to make an inner join. Assuming that you have 3 tables in a forum system: "users" for user profile, "forums" for forums... Read More
How To Get the ID Column Auto-Incremented?
Added on Wed, Jan 6, 2010
Many tables require an ID column to assign a unique ID number for each row in the table. For example, if you have a table to hold forum member profiles, you need an ID number to identify each member. To allow MySQL server to... Read More
How To Get the Last ID Assigned by MySQL?
Added on Wed, Jan 6, 2010
If you use an ID column with AUTO_INCREMENT attribute, you can use the mysql_insert_id() function to get the last ID value assigned by the MySQL server, as shown in the sample script below: <?php include ... Read More
How To Move Uploaded Files To Permanent Directory?
Added on Wed, Jan 6, 2010
PHP stores uploaded files in a temporary directory with temporary file names. You must move uploaded files to a permanent directory, if you want to keep them permanently. PHP offers the move_uploaded_file() to help you moving uploaded... Read More
Why Do You Need to Filter Out Empty Files?
Added on Wed, Jan 6, 2010
When you are processing uploaded files, you need to check for empty files, because they could be resulted from a bad upload process but the PHP engine could still give no error. For example, if a user typed a bad file name in the upload... Read More
What Are the File Upload Settings in Configuration File?
Added on Wed, Jan 6, 2010
There are several settings in the PHP configuration file related to file uploading: file_uploads = On/Off - Whether or not to allow HTTP file uploads. upload_tmp_dir = directory - The temporary directory used for ... Read More
What does a special set of tags <?= and ?> do in PHP?
Added on Wed, Jan 6, 2010
The output is displayed directly to the browser. Read More
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example? -
Added on Wed, Jan 6, 2010
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. Read More
How do you define a constant? -
Added on Wed, Jan 6, 2010
Via define() directive, like define ("MYCONSTANT", 100); Read More
How do you pass a variable by value? -
Added on Wed, Jan 6, 2010
Just like in C++, put an ampersand in front of it, like $a = &$b Read More
Will comparison of string "10" and integer 11 work in PHP? -
Added on Wed, Jan 6, 2010
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared. Read More
Explain the ternary conditional operator in PHP? -
Added on Wed, Jan 6, 2010
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed. Read More
What’s the special meaning of __sleep and __wakeup? -
Added on Wed, Jan 6, 2010
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them. Read More
Would you initialize your strings with single quotes or double quotes? -
Added on Wed, Jan 6, 2010
Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable... Read More
How come the code <?php print "Contents: $arr[1]"; ?> works, but <?php print "Contents: $arr[1][2]"; ?> doesn’t for two-dimensional array of mine?
Added on Wed, Jan 6, 2010
Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked. Read More
What will work faster?
Added on Wed, Jan 6, 2010
For printing out strings, there are echo, print and printf. Explain the differences ?
Added on Wed, Jan 6, 2010
echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and... Read More
What do you need to use the image functions in PHP?
Added on Wed, Jan 6, 2010
You need to have access to the GD Library in order to use the image functions in PHP. Read More
|