Just got a good article about this:
Understanding $_SERVER[’PHP_SELF’], $PHP_SELF, $_SERVER[’REQUEST_URI’] and $_SERVER[’SCRIPT_NAME’] in PHP and when to use what .
Basically, $PHP_SELF is deprecated and should not be used because it will not work without register_globals being enabled. As of PHP 4.2.0 the default for the PHP directive register_globalswent from on to off.
Monday, February 05, 2007
Saturday, February 03, 2007
New Blogger sucks
Almost everytime I click buttons in new version blogger to save my settings and publish my posts, it'll display an error.
Now I have to use email to blogging.
I hope this issue be resolved soon.
It really SUCKS!
(This is an email-publishing test)
Thursday, February 01, 2007
PHP Apache tips
(1) How to log errors in PHP instead of displaying them on the page?
Use the following lines in php.ini:
; Print out errors (as a part of the output).
information.display_errors = off
; Even when display_errors is on, errors that occur during PHP's startup; debugging.display_startup_errors = Off
; Log errors into a log file (server-specific log, stderr, or error_log (below));
sites.log_errors = On
; Set maximum length of log_errors.
log_errors_max_len = 1024
; Do not log repeated messages.
ignore_repeated_errors = Off
; Ignore source of message when ignoring repeated messages.
ignore_repeated_source = Off
; Log errors to specified file.
error_log = "logs/errors.log"
(2) How to find backend SQL errors?
Set the following line in php.ini:
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and SQL-Errors will be displayed.
mysql.trace_mode = On
(3) How to avoid exposing index structures for a folder?
Set the following lines in httpd.conf:
## DirectoryIndex: sets the file that Apache will serve if a directory is requested.
DirectoryIndex index.php
In such a way, request for a directory will be redirected to the file "index.php".
(4) How to use logging in Apache server?
Use the following 2 settings:
## ErrorLog: The location of the error log file.
ErrorLog logs/error.log
## LogLevel: Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
(5) How to do directory-level access configuration for Apache Http Server?
Here's an example:
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Details can be found in http://httpd.apache.org/docs/2.2/mod/core.html#options .
Use the following lines in php.ini:
; Print out errors (as a part of the output).
information.display_errors = off
; Even when display_errors is on, errors that occur during PHP's startup; debugging.display_startup_errors = Off
; Log errors into a log file (server-specific log, stderr, or error_log (below));
sites.log_errors = On
; Set maximum length of log_errors.
log_errors_max_len = 1024
; Do not log repeated messages.
ignore_repeated_errors = Off
; Ignore source of message when ignoring repeated messages.
ignore_repeated_source = Off
; Log errors to specified file.
error_log = "logs/errors.log"
(2) How to find backend SQL errors?
Set the following line in php.ini:
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and SQL-Errors will be displayed.
mysql.trace_mode = On
(3) How to avoid exposing index structures for a folder?
Set the following lines in httpd.conf:
## DirectoryIndex: sets the file that Apache will serve if a directory is requested.
DirectoryIndex index.php
In such a way, request for a directory will be redirected to the file "index.php".
(4) How to use logging in Apache server?
Use the following 2 settings:
## ErrorLog: The location of the error log file.
ErrorLog logs/error.log
## LogLevel: Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
(5) How to do directory-level access configuration for Apache Http Server?
Here's an example:
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Details can be found in http://httpd.apache.org/docs/2.2/mod/core.html#options .
Wednesday, January 31, 2007
Configure MySQL with PHP
Product version: PHP5 (Non-installed version for windows), MySQL5 (Non-installed version for windows).
Steps:
(1) Use php.ini-recommended as the default ini file by renaming it to php.ini.
(2) In the development environment, it's useful to set display_errors = on. When moving the web application to production, this switch should be turned off.
(3) Check the document root in the following line: doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" .
(4) Specify the loadable module directory extension_dir = "C:\php5\ext" .
(5) Enable php_mysql.dll inside of php.ini by removing semicolon from the line ;extension=php_mysql.dll .
(6) PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. So add "C:\php5\" to PATH environmental variable.
(7) Specify upload_tmp_dir and session.save_path if necessary.
(8) Copy some extension pointers in the orginal php.ini file into the new php.ini file.
Steps:
(1) Use php.ini-recommended as the default ini file by renaming it to php.ini.
(2) In the development environment, it's useful to set display_errors = on. When moving the web application to production, this switch should be turned off.
(3) Check the document root in the following line: doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" .
(4) Specify the loadable module directory extension_dir = "C:\php5\ext" .
(5) Enable php_mysql.dll inside of php.ini by removing semicolon from the line ;extension=php_mysql.dll .
(6) PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. So add "C:\php5\" to PATH environmental variable.
(7) Specify upload_tmp_dir and session.save_path if necessary.
(8) Copy some extension pointers in the orginal php.ini file into the new php.ini file.
Simplest way to configure Apache Http Server with PHP
Product Version: Apache Http Server 2.2, PHP 5.
Non-install version of php is used.
Modify file/conf/httpd.conf by adding the following lines:
LoadModule php5_module "C:/php5/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php5"
C:/php5 is the location where php5 is installed.
Modify php.ini by specifying:
doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"
Non-install version of php is used.
Modify file
LoadModule php5_module "C:/php5/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php5"
C:/php5 is the location where php5 is installed.
Modify php.ini by specifying:
doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"
Wednesday, January 10, 2007
Interoperability between oracle jdbc driver and oracle database
There are some data type mapping issues when using oracle jdbc driver 10 with oracle 9i database, which is explained on Oracle JDBC FAQ . Old version mapping can also be done by setting the value of "V8Compatibility" to true.
Interesting stuff about portlet development
Concepts of portal and portlet development are quite well explained in the following articles:
Introducing Portlet Specification 1 ,
Introducing Portlet Specification .
Sunday, December 17, 2006
Call web service from C# client using basic authentication
The C# class Credentials is used to put authentication information into the SOAP header, not the HTTP header, which would lead to some problem when calling a java-based web service.
In order to invoke web service protected by basic authentication from a C# client, we must override the GetWebRequest() method.
The solution is as follows:
protected override System.Net.WebRequest GetWebRequest(Uri uri){
System.Net.WebRequest request = base.GetWebRequest (uri);
string username = "Test";
string password = "Test";
string auth = username + ":" + password;
byte[] binaryData = new Byte[auth.Length];
binaryData = Encoding.UTF8.GetBytes(auth);auth = Convert.ToBase64String(binaryData);
auth = "Basic " + auth;
request.Headers["AUTHORIZATION"] = auth;
return request;
}
2 related posts can be found at: thescripts developer network , Clinton Davidson's blog .
In order to invoke web service protected by basic authentication from a C# client, we must override the GetWebRequest() method.
The solution is as follows:
protected override System.Net.WebRequest GetWebRequest(Uri uri){
System.Net.WebRequest request = base.GetWebRequest (uri);
string username = "Test";
string password = "Test";
string auth = username + ":" + password;
byte[] binaryData = new Byte[auth.Length];
binaryData = Encoding.UTF8.GetBytes(auth);auth = Convert.ToBase64String(binaryData);
auth = "Basic " + auth;
request.Headers["AUTHORIZATION"] = auth;
return request;
}
2 related posts can be found at: thescripts developer network , Clinton Davidson's blog .
Subscribe to:
Posts (Atom)