We can create MySQL database with the use of mysql_create_db($databaseName) to create a databa...
Friday, June 22, 2007
Wednesday, June 13, 2007
How can I execute a PHP script using command line?
6:22 PM
No comments
Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environme...
How To Upload the Files to a Table?
6:19 PM
No comments
To store uploaded files to MySQL database, you can use the normal SELECT statement as shown below:
<?php
$con = mysql_connect("localhost", "", "");
mysql_select_db("fyi");
$error = $_FILES['fyicenter_logo']['error'];
$tmp_name = $_FILES['fyicenter_logo']['tmp_name'];
$size = $_FILES['fyicenter_logo']['size'];
$name = $_FILES['fyicenter_logo']['name'];
$type = $_FILES['fyicenter_logo']['type'];
print("
\n");
if ($error == UPLOAD_ERR_OK && $size > 0) {
$fp = fopen($tmp_name, 'r');
$content = fread($fp, $size);
fclose($fp);
$content...
Explain when to use GET or POST. Provide example for both the ways.
6:12 PM
No comments
Both GET and POST are used to collect data from a form. However, when security is desired $_POST should be used. When the $_ POST variable is used, all variables used are NOT displayed in the URL. Also, they have no restrictions to the length of the variables. GET should be used when the interaction with the form is more like a question. For e.g. firing a query etc. POST should be used more often when the interaction is more like an order or the interaction changes the state of the resource.
POST example:
Name:
Age:
On clicking submit the...
Explain the purpose of isset() functions by illustrating an example.
6:09 PM
No comments
isset() function is used to determine if a variable is set or not. It returns true if the variable exists. If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set.
Example:
$a =”sample”;
var_dump(isset($a)); //tr...
Friday, June 8, 2007
What are the different types of Errors in PHP?
There are three basic types of run time errors in PHP:
1. Notices: These are small, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although the default behavior can be changed.
2. Warnings: Warnings are more severe errors like attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These...
Wednesday, June 6, 2007
What are the differences between require and include, include_once?
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal erro...
Sunday, June 3, 2007
Subscribe to:
Posts (Atom)