Wednesday, May 18, 2011

fsdfsdfsdf

The following is one sample





powered by likeForex.com

Friday, September 4, 2009

redirect 404, not found page

Have a file at in the public_html or htdocs folder of your website called .htaccess with this in it:
Code:
ErrorDocument 404 /index.php

Thursday, July 2, 2009

php2

HTML forms contain at least the following elements:

A method: The method can be either POST or GET. Variables passed from a form to a PHP script are placed in the superglobal called $_POST or $_GET, depending on the form method.
An action
A submit button

In your HTML code, the first line of a form looks something like this:
"

Value 1:


Value 2:



Calculation:

add

subtract

multiply

divide



if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) {
"

php-1

;
\"
// /*
1.$ The variable name cannot begin with a numeric character, but it can contain numbers and the underscore character (_).
2.two main types of variables in your PHP code: scalar and array. Scalar variables contain only one value at a time, and arrays contain a list of values or even another array.
3.assign a value to a variable, you usually assign a value of one of the following types: Integers, Floating-point numbers ("floats" or "doubles"), Strings. Text or numeric information, specified within double quotes (" ") or single quotes (' ').
4.Variables can be local or global, the difference having to do with their definition and use by the programmer and where they appear in the context of the scripts you are creating.
5.a set of predefined variables is available to you. Some of these predefined variables are called superglobals, meaning that they are always present and available to all of your scripts, without any intervention by you, the programmer.
$_GET contains any variables provided to a script through the GET method.
$_POST contains any variables provided to a script through the POST method.
$_COOKIE contains any variables provided to a script through a cookie.
$_FILES contains any variables provided to a script through file uploads.
$_ENV contains any variables provided to a script as part of the server environment.
$_SESSION contains any variables that are registered in a session.
6.A constant is an identifier for a value that cannot change during the course of a script.
Unlike simple variables, constants do not have a dollar sign before their name, and they are usually uppercase to show their difference from a scalar variable.
define("MYCONSTANT", "This is a test of defining constants.");
predefined constant variables:
__FILE__ The name of the script file being parsed.
__LINE__ The number of the line in the script being parsed.
PHP_VERSION The version of PHP in use.
PHP_OS The operating system using PHP.

Monday, June 8, 2009

Tomcat + Apache HTTP: Servers Connecting Guide

http://lkamal.blogspot.com/2008/11/tomcat-apache-http-server-connect-guide.html

Apache Tomcat is a Servlet/JSP container and used to deploy dynamic Java contents like JSPs and Servlets. Tomcat has some web server capabilities, however it is not a full blown web server to serve high traffic web sites. In the meantime Apache HTTP server is a full blown web server. So in general Tomcat is configured along with Apache HTTP server to maintain a healthy web site with dynamic content. This article will cover the steps of configuring HTTP server and Tomcat connection, however this will not discuss installation details of Apache or Tomcat.

System Requirements
Apache HTTP server installed
download from here
we used version 2.2.10 for this article
Apache Tomcat installed
download from here
we used version 5.5 here
Short Names
Followings are the short names used to denote folders used in this article.
%APACHE_HTTP_HOME%
denotes Apache HTTP Server installation directory. In our testing machine, it is "D:\ASF\Apache"
%CATALINA_HOME%
Tomcat installation directory; for example: "D:\ASF\Tomcat"
Connection Configurations
The connection between HTTP server and Tomcat will be done using Apache Tomcat Connector module named mod_jk which is configured inside Apache HTTP server. For that first download the correct version of connector from here.

For version 2.2.10 of Apache HTTP; correct connector version is 2.2.4 (available here). Make sure to download the correct version, as incorrect version may result in errors.

Mod_jk configuration
Now the downloaded mod_jk module must be configured in Apache HTTP server. First rename the above downloaded file say mod_jk-1.2.26-httpd-2.2.4.so to "mod_jk.so". In Apache server, module files are stored under %APACHE_HTTP_HOME%\modules folder. Now copy the mod_jk.so file into this folder.

Then open the HTTP server configuration file named httpd.conf. It's located in %APACHE_HTTP_HOME%\conf folder. This file has a number of lines used to load Modules starting with "LoadModule ". Add the following line below these lines.

LoadModule jk_module modules/mod_jk.so

Now the downloaded mod_jk module is added into Apache server.

Tomcat Server Information
We need a new properties file to store details about the Tomcat server. Create a new file named workers.properties inside %APACHE_HTTP_HOME%\conf folder with the following content.

worker.list=localTomcat
worker.localTomcat.host=localhost
worker.localTomcat.port=8009
worker.localTomcat.type=ajp13

Pay attention to the above port 8009; this is the port defined inside %CATALINA_HOME%\conf\server.xml file as follows.




If the port in AJP 1.3 connector section of Tomcat is different than 8009, change the above workers.properties file to match that.

Now we need to configure the workers.properties file in %APACHE_HTTP_HOME%\conf\httpd.conf file. For that add the following lines after the line that we added into httpd.conf in a previous step.

JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log

Now everything is setup. However still we have not yet defined the important part; which user requests to be forwarded to Tomcat server from Apache server.

URL Patterns
Following is the format of those configurations.

JkMount
- the url pattern that you need to forward to Tomcat
- the worker name defined in workers.properties file.
We can set up multiple url patterns as follows.

JkMount /myProject/* localTomcat
JkMount /*.jsp localTomcat
JkMount /*.do localTomcat

First one will send all requests for a web application named "myProject" to Tomcat while the second will send all requests ending with ".jsp". The third line configures for all requests ending with ".do" (many use .do extension with Struts actions).

Add required configuration lines as above into httpd.conf (just after the lines we added in above steps).

Setup Completed
Now try the URLs of your application as follows (using Apache port number, rather than Tomcat port number). We assumed Apache HTTP server is running on port 80. Following as some sample urls for the above configurations.

http://localhost/myProject/
http://localhost/testApp/main/admin.jsp
http://localhost/strutsApp/login.do

Now Apache will direct all these request to Tomcat (running on a different port) and serve the client smoothly.

test whether tomcat is successful.
http://localhost:8080/

Thursday, June 4, 2009

start MySQL on Window

start MySQL on Windows, follow these steps:

Open a Command Prompt window.

In Windows XP, choose StartðAll ProgramsðAccessoriesðCommand Prompt.

Change to the folder where MySQL is installed.

For example, type cd C:\Program Files\MySQL\MySQL Server 5.0.

Your cursor is now located in the MySQL folder.

Change to the bin subfolder by typing cd bin.

Your cursor is now located in the bin subfolder.

Start the MySQL Server by typing mysqld --install.

Install Apache 2.2 with PHP 5 on Windows Vista

http://anderson-web.blogspot.com/2008/01/install-windows-vista-apache-22-mysql.html

I spent some hours installing Apache-PHP on Windows vista, and I think it will be helpful to publish the detail instructions.

Suggestion: It is always a good practice, especially if you are a beginner, to make a backup of the configuration files. For example you can follow the pattern: filename-YYDDMMhhmm.ext

Installing Apache HTTP Server (2.2.6)
Download Apache 2 binaries for windows and save it in the desktop - for example. This version has fixed the problems with the Apache Monitor.

If you have any web server, like IIS, or other application using the port 80, stop it before start the installation. Type the following at the prompt for find out if the port 80 is already taken (look for the pattern '%s':80 in the second column), c:\> netstat -ao find /i "listening"

Open the command window with administrator privileges. Go to start > All programs > Accessories. Right-click on Command Prompt and select run as administrator. Note: It is not necessary to stop the User Account Control (UAC).

Run the setup from the command window just opened. Browse to the directory where you save apache, c:\users\user-name\desktop in this case, and type in the command prompt, c:\users\user-name\desktop> msiexec /i apache_2.2.6-win32-x86-no_ssl.msi

Install Apache in its default location, C:\Program Files\Apache Software Foundation\Apache2.2 , or choose one appropriate for you.

When the wizard ask you for the domain, server name, and administrator email write the appropriate values if you are installing a production server, otherwise write the values suggested between parenthesis ().

Choose the default server on port 80 for all users option.

When the install finishes you can try http://localhost/ in the web browser and it should show you "It works". :)

For stop, start, and restart Apache HTTP Server, go to Start > All programs > Apache HTTP Server 2.2.6 > Control Apache Server, and right-click on the desire option and select run as administrator.

Troubleshooting: The log file of install and general errors is located on the folder C:\Program Files\Apache Software Foundation\Apache2.2\logs. You can also use the option on Start > All programs > Apache HTTP Server 2.26 > Configure Apache Server > Test configuration to see if there is any error on the configuration file of Apache, httpd.conf.

Installing PHP (5.2.5)
Download the windows binaries zip package of php. I tried to use the installer, but I got an error configuring PHP with CGI as well as with module; something like "...Parent: Received restart signal -- Restarting the server....Child 8448: Exit event signaled. Child process is ending" in the error.log file. So we proceed with a manual installation. Anyway, manual installation is always recommended because there is more things to learn :).

Unzipped the files in c:\php. A location without spaces is preferred. (You could read the install.txt file for further information about it).

Copy the file php.ini-recommended to a new file named php.ini

Go to start and right-click on computer and click on properties. In the new opened window, click on Advanced system settings, on the left panel, and the System properties window will be opened. Select the tab advanced, and click on Environment variables button. In the system variables panel, look for the Path variable and click in the Edit button. Add at the end of the Path environment variable, the path were PHP is installed, ...;C:\php\ . This indicates the path of the file php5ts.dll, the main dll of PHP.

Open the notepad or your favorite text editor with administrator privileges and open the httpd.conf located in C:\Program Files\Apache Software Foundation\Apache2.2\conf. Append the following lines to the file httpd.conf at the end, to configure PHP as a module.
PHPIniDir "C:/php/"
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"


Restart apache. Go to Start > All programs > Apache HTTP Server 2.2.6 > Control Apache Server, and right-click on the restart option and select run as administrator.

Do the following for test the Apache-PHP integration. Create a file called test.php in the folder C:\Program Files\Apache Software Foundation\Apache2.2\htdocs with he content:

Open the web browser and go to http://localhost/test.php. You should see general information about the current state of the PHP installed.

Next, I will publish general additional settings that I commonly use to personalize the developing environment.