Monthly Archives: January 2010

Querying XML type data using SQL – TABLE(XMLSEQUENCE)

The table(xmlsequence) can be used to return values of multiple nodes from an XML. XMLSequence returns a VARRAY of XMLType. It splits multi-value results from XMLTYPE queries into multiple rows. The TABLE function, can be used to query this VARRAY. … Continue reading

Posted in PL/SQL - XML | Tagged , | Leave a comment

Retrieve the Session ID of the current session using PHP

There are two ways to get the session id for a visitor. A call to the session_id() function will return the session ID value. Another way is to use the built-in constant SID. SID contains a string of session ID … Continue reading

Posted in PHP sessions | Tagged , | Leave a comment

Session IDs in PHP

A session ID is an identification string of a session. The PHP engine maintains multiple sessions concurrently one per visitor to the site. Session IDs are created and maintained by the PHP engine to identify sessions. When a visitor comes … Continue reading

Posted in PHP sessions | Tagged | Leave a comment

Retrieve values from the current session in PHP

We can retrieve the values stored in a session by using the pre-defined associative array called $_SESSION. The following PHP script shows you how to retrieve values from the session: <?php session_start(); print("<html><b>"); $_SESSION[’sitename’] = "W3M’; $sitename = $_SESSION["sitename"]; print("Value … Continue reading

Posted in PHP sessions | Tagged , | Leave a comment

Save information in the current session in PHP

The pre-defined associative array called $_SESSION can be used to store session specific information. The following PHP script shows you how to save values to the session: Example code: <?php session_start(); print("<html><b>");   $_SESSION["sitename"] = "W3M"; print("A value saved in … Continue reading

Posted in PHP sessions | Tagged , | Leave a comment

How to enable session support in PHP

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 can be done by setting session.auto_start = 1 in php.ini. Turning on … Continue reading

Posted in PHP sessions | Tagged , | Leave a comment

File upload related settings in php.ini

There are a few settings in the PHP configuration file (php.ini) 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 storing files when doing … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

Upload and store files in Mysql using PHP : Part 2 – PHP file processing

To store uploaded files to MySQL database, you can use the normal INSERT statement as shown in the php example listed below: <?php $con = mysql_connect("localhost", "", ""); mysql_select_db("w3m"); $error = $_FILES[’w3img’][’error’]; $tmp_name = $_FILES[’w3img’][’tmp_name’]; $size = $_FILES[’w3img’][’size’]; $name = … Continue reading

Posted in PHP File Handling | Tagged , , , | Leave a comment

Upload and store files in Mysql using PHP : Part 1 – Design MySql Table

A MySQL database can be used to store files uploaded using PHP.The table columns must be created using BLOB columns to hold the binary file.The blob column can hold up to 65,535 characters. Example code: <?php $con = mysql_connect("localhost", "", … Continue reading

Posted in PHP File Handling | Tagged , , , | 1 Comment

Check for empty files in http upload using PHP

Bad upload process could result in empty files and developers need to check for empty files before using them, because the PHP engine could give no error. For example, if a user typed a bad file name in the upload … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

Detect http file upload errors in PHP

Errors that occur during file upload create an error code in $_FILES[$field]['error']. Possible error code values are: UPLOAD_ERR_OK (0) – There is no error, the file uploaded with success. UPLOAD_ERR_INI_SIZE (1) – The uploaded file exceeds the upload_max_filesize directive in … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

Move uploaded files to a different directory using PHP

PHP stores uploaded files in a temporary directory with temporary file names. It is a good practise to move uploaded files to a permanent directory, if you want to keep them permanently. The move_uploaded_file() function can be used to move … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

Retrieve uploaded file information using PHP

When a file upload form posts the file to a Web server, the called PHP script specified in the form action attribute is used to process the file. This receiving PHP script can get the uploaded file information through the … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

using FORM tag appropriately for uploading files

The files specified in the will be transferred from the browser to the Web server by using a HTTP Post. This transferring (uploading) process is controlled by a properly written tag. Example: <FORM ACTION=receiving.php METHOD=post ENCTYPE=multipart/form-data> The METHOD must be … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

File Upload dialog using PHP and HTML

File upload allows visitors to specify a file on the browser’s system and submit it to the Web server. This is a useful feature for interactive Web sites. To present an input field on your Web page to allow users … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

Reset Identity of a table

To reset the identity value to 0, the table should be empty or else it will error out. The faster way to do this, remove the contents of the table and reset the identity, is to use the TRUNCATE TABLE … Continue reading

Posted in MSSQL Basics | Tagged , | Leave a comment

Remove an empty directory in php

An empty existing directory can be removed by using the rmdir() php function. Example use of rmdir(): <?php if (file_exists("/temp/test")) { rmdir("/temp/test"); print("Directory removed.\n"); } else { print("Directory does not exist.\n"); } ?> This script will print: Directory removed. If … Continue reading

Posted in PHP File Handling | Tagged , | Leave a comment

Create a directory in php

The mkdir() php function can be used to create a directory provided that the necessary file permissions exist. Example on mkdir(): <?php if (file_exists("/temp/test")) { print("Test Directory already exists.\n"); } else { mkdir("/temp/test"); print("Test Directory created.\n"); } ?> Output – … Continue reading

Posted in PHP File Handling | Tagged , | Leave a comment

Programatically monitor directory for changes using c#

To check for changes to a directory i.e a new file or folder added to the directory or a file or folder deleted from the directory, we must use the filesystemwatcher class. This class allows us to raise events when … Continue reading

Posted in C# File Handling | Tagged , , , | Leave a comment

Programatically change file extension using c#

To change a file extension of a file using csharp, we must use the Path class. The Path class allows us to parse individual parts of a file system path. The static Path.ChangeExtension method can be used to change the … Continue reading

Posted in C# File Handling | Tagged , | 1 Comment