Saturday July 31, 2010 @ 04:22:13 GMT+10    ( Weather:  18°C / 64°F  -  Partly Cloudy )
Home » Weblog Archives

Powered byD's Bloggie
Weblog Archive browse by category ...
 → Category :
Display order:
Page 1 of 2   ( 17 entries , showing 1 - 10 )
    1 2 Next  

How to enable Gzip compression on output buffer - 12:59 pm
Browser , Coding , Guides , PHP  -  poster 

I've been updating this site since last month. One of the things I added is able to serve gzip-encoded page. On top of that, my site is also able to serve gzip-encoded CSS and JS file heh Just scroll to the bottom of every page and you'll notice a line that says something like "Gzip enabled , CSS compressed , JS compressed". This will give an indication whether they are enabled or not. In other words, this will make pages load faster as well as saving some tiny bandwidth.

I've written a how-to thing that gives you an idea how to achieve that with PHP using ob_gzhandler(). For this to work you'll need the appropriate version of PHP, zlib extension and web browser that supports compressed web page.

Link: [PHP] How to enable Gzip compression on output buffer

Next topic will be on how to shrink, compress and cache CSS/JS files. Those who're using heavy AJAX and CSS styling will benefit from this.

Last edited: Wed 2007-05-30 @ 15:58 , by DaRen 2 time(s)

IP2Country binary database maker - 2:48 pm
Now in PHP....
Coding , PHP  -  poster 

Half way through the site updates with lots of new codes and I thought the below script might be useful to some people... so, here you go !

IP2Country binary database maker (PHP)

Note: It's now added to my dev list here, always check there for latest news.

The IP2Country binary database maker in PHP that I written is a port from the original Python script from L. Petersen in Weird Silence, or a direct link to the source code zip file (inside makedb.py file).

The binary database created by this script can be used for IP to country lookup. If you need the script on how to use the database, visit Weird Silence - IP to Country. They have several languages for the implementation (eg. C#, PHP, Python, C, Delphi).

// +----------------------------------------------------------------------+
// | IP2Country binary database maker                                     |
// | Copyright (C) 2007  Darren (http://ahkuan.com/weblog/199.html)       |
// |                                                                      |
// | File    : ip_csv2dat.php                                             |
// | Started : Monday, May 7, 2005                                        |
// | Version : 1.0                                                        |
// +----------------------------------------------------------------------+
// |                                                                      |
// | This is a PHP port with little modification from original            |
// | Python script coded by                                               |
// |        L. Petersen , visit http://weirdsilence.net/software/ip2c/    |
// |                                                                      |
// | What this script does is it converts the CSV database from           |
// | IP-to-Country and GeoIP into binary database for quicker lookup      |
// |                                                                      |
// | Websites:                                                            |
// | IP-to-Country  http://ip-to-country.webhosting.info                  |
// | Maxmind: GeoIP  http://www.maxmind.com/app/ip-location               |
// |                                                                      |
// | Download latest CSV database:                                        |
// | http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip |
// | http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip   |
// |                                                                      |
// | *NOTE*                                                               |
// | Let me know if there is anything wrong with the code, especially     |
// | whether the formatting code used in PHP's pack() function is the     |
// | same as the Python or not. I have no Python coding experience at     |
// | all when I'm porting the original Python script to PHP... so only    |
// | God knows what mistake I've made unless you tell me ;)               |
// |                                                                      |
// | Also, I'm happy to hear if you have any improvements/suggestions.    |
// | Use the 'Contact me' link on my page to contact me.                  |
// |                                                                      |
// +----------------------------------------------------------------------+


Download

  • ip_csv2dat.rar - PHP Source code rarred (CSV database included) (748 KB)
  • ip_csv2dat.zip - PHP Source code zipped (CSV database included) (1 MB)

*Edit 2007.5.9* Added zipped file source code for download
*Edit 2007.5.30* Added to my dev list.

Tip: Larger Upload Size Limit For PHP - 12:46 pm
Guides , PHP  -  poster 

Below is a quick guide to get PHP accept larger upload file size.

Step 1.
Edit your PHP.INI file on the server
MAX_EXECUTION_TIME = 2400
MEMORY_LIMIT = 128M
POST_MAX_SIZE = 128M
UPLOAD_MAX_FILESIZE = 128M


Step 2.
Create a .htaccess file in your root folder.
php_value post_max_size 128M
php_value upload_max_size 128M


Step 3.
For HTML <FORM>
<input type="hidden" name="max_file_size" 
value="134217728">

Last edited: Wed 2007-01-17 @ 19:56 , by DaRen 3 time(s)

Installing Apache 2.2.3, PHP 5.1.4 and MySQL 5.0.24 on WindowsXP (SP2) - 6:05 pm
since when it's so hard to setup a simple LAMP?
Guides , PHP , Site Issue , SQL , Web Hosting  -  poster 

Last revised: 2007.01.17

I've enough headache last night trying to figure out how to make Apache 2.2.3 and PHP 5.1.4 to work together on Windows XP. After several hours of tweaking and changing the settings, I finally gave up and search for help on the web. It seems it's not my fault that they can't work in harmony. Most of the tutorial on the web is not detailed enough and the readme from Apache and PHP is gay. I'm no expert or guru on both of them, but I'll write down the steps required to get them working and hope that one day I can make somebody's life easier if they encountered the same problem as me =)

Installing Apache
  1. Go to Apache HTTP server project website to download the binary for windows. This guide uses Apache 2.2.3.
  2. Open the file and follow the prompt. When it ask for the Network Domain and Server Name, use "localhost" if you're setting up a local server on your computer for development purpose, otherwise fill in the address and name according to your server. In the Administrator’s Email Address field, use any email address (e.g. "admin@localhost").
  3. Continue clicking next and choose the setup type and path to install and complete the installation.
  4. If Windows (SP2) firewall prompt to ask about the program, just click "Unblock".
  5. At this point installation is completed, Apache HTTP server should be running as a service if everything is ok. Open your browser, type in http://localhost/ in the URL bar. You should see "It works !" on the page.
  6. To customize the httpd.conf file (located in /conf in Apache folder), open with any text editor. Look for DocumentRoot, change the path if you want. For example:
    DocumentRoot "C:/Documents and Settings/user/My Documents/My Website/localhost/www"
    The default path will be pointing to /htdocs in your Apache folder.
  7. If you changed the DocumentRoot mentioned above, remember to scroll down and look for a line that looks like
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "C:/...">

    Change the path in the <Directory> tag to the same you set for DocumentRoot in above. For example:
    <Directory "C:/Documents and Settings/user/My Documents/My Website/localhost/www">
    If you don't change it, you'll get Permission Denied when you browse http://localhost
  8. Change any other settings to suit your server or for scricter security. The above is sufficient for normal static html hosting. See below if you need a script parser like PHP for dynamic page output.

Enable mod_rewrite for URL rewrite
See Enable mod_rewrite in Windows in another entry in my weblog.

Installing PHP
  1. Go to PHP website to download the binary for windows. This guide uses PHP 5.1.4.
  2. Please take note that if you followed the below steps and it's still not working with Apache, continue to read down to the section Another way to make Apache and PHP work together.
  3. Unzip the contents to the path you desire (eg. C:\php\).
  4. Go to Control Panel -> System -> Advanced tab -> Click on Environment Variables. In the System variables list, look for the variable name Path. Select it and click on Edit. Append
    ;C:\php
    at the back of the variable value.
  5. Now go back to the PHP folder (eg. C:\php\), make a copy of the file php.ini-recommended and rename it to php.ini. Open the php.ini file with text editor. *Note* This guide uses php.ini-recommended file, you can use the php.ini-dist if you know what you're doing.
  6. If you changed the value of DocumentRoot in httpd.conf file mentioned above (Installing Apache, Step 6), you need to change the doc_root value to , for example:
    doc_root = C:/Documents and Settings/user/My Documents/My Website/localhost/www
  7. Save the php.ini. Now open the Apache httpd.conf file, look for the "LoadModule" section. At the bottom of the LoadModule block, insert the following lines:
    # For php5 module
    LoadModule php5_module "c:/php/php5apache2.dll"
    AddType application/x-httpd-php .php
    # Configure the path to php.ini
    PHPIniDir "c:/php"


    You can add another optional line if you know what you're doing:
    AddType application/x-httpd-php .php-source .phps

    *Updated 2007-01-17*
    If you found a DLL file named php5apache2_2.dll in the PHP build you downloaded, change
    LoadModule php5_module "c:/php/php5apache2.dll"
    to
    LoadModule php5_module "c:/php/php5apache2_2.dll"
  8. This step is optional. Scroll down a bit and look for something like
    <IfModule dir_module>
    DirectoryIndex index.html
    </IfModule>

    Made changes to the DirectoryIndex and add index.php. The modified one should looks like
    <IfModule dir_module>
    DirectoryIndex index.php index.html
    </IfModule>
  9. Save the file and restart your computer (dont ask, just restart).
  10. Create a text file in your document root (eg. C:/Documents and Settings/user/My Documents/My Website/localhost/www), insert
    <?php phpinfo(); ?>
    into the file, save it and rename it to phpinfo.php.
  11. Start the Apache server as a service if it's not. Apache should be able to load the PHP module and start running. To check if everything is working, open your browser and type in http://localhost/phpinfo.php. You should get a page containing information on your installation of PHP and its settings. If you don’t, try restarting Apache. If Apache says it can't load the php5apache2.dll or it says that the module can't be found refer to Another way to make Apache and PHP work together section below

To manipulate the Apache web server via command line, open a command prompt in Windows, navigate to the folder /bin in your Apache folder and try the following commands.

Some useful command for Apache web server
Command Description
httpd -k install Install Apache as a Windows service
httpd -k uninstall Remove Apache as a Windows service. If you didn't install Apache using windows installer and you want to uinstall it, it's better you call this command before you remove the folder manually.
httpd -k start Tell Apache to start
httpd -k restart Tell Apache to do a graceful restart
httpd -k stop Tell Apache to shutdown



Installing MySQL
  1. Go to MySQL website to download the binary for windows. This guide uses MySQL 5.0.24.
  2. Extract the zip file and run the Setup file.
  3. You should choose the Custom installation, to allow you to select an installation path. Click Next to continue and install it.
  4. When you're asked register with MySQL, Skip it if you don't have time for it. Once the installation is complete, tick the option to launch the MySQL Configuration Wizard and finish it.
  5. On the configuration wizard, select the Standard Configuration option on the first screen and click Next.
  6. On next screen, leave the 2 checkbox in default, check the 2nd one (include Bin Directory in Windows Path) if you want to enter MySQL commands from the command prompt without first having to navigate to the MySQL \bin directory.
  7. On next screen, you can leave the password field blank for root user for you can assign a password for it. Depends on you but I strongly recommend you assign a password.
  8. Click Execute on the next screen to finish the installation. Restart your computer.
  9. After rebooting, to check if MySQL is running properly or not, open a command prompt and type the following command:
    mysql -u root -p
    You need to navigate to \bin in your MySQL folder if you didn't ask MySQL to setup the Path variable during installation. If you didn't setup the password for root user, just remove the -p in the above command.
    If you get "Can't connect to MySQL server on 'localhost'" error message, that means MySQL server is not started yet. Go to Control Panel -> Administrative Tools -> Services and look for MySQL entry. Right click and select Start. Once it's started, you can make a connection to the server using the command stated above.
    Alternatively, you can invoke MySQL by calling the following command:
    mysqld-nt --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" MySQL
  10. Once you're connected to server using the root user account, type the following command:
    mysql> show schemas;

    You should get the following results:
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | test               |
    +--------------------+
    3 rows in set (0.26 sec)
  11. Now you need to get PHP to talk to MySQL. Open the php.ini look for "Paths and Directories" section and find extension_dir, change it to:
    extension_dir = "c:/php/ext"
  12. Scroll down and look for ;extension=php_mysql.dll. You need to uncomment it by removing the ';' (semi-colon). It should looks like
    extension=php_mysql.dll
  13. This step is optional. Uncomment the ;extension=php_mbstring.dll if you need multibyte string functions (eg. to process unicode data)
  14. Save the file and start/restart Apache.
  15. *Hint* I strongly suggest that you should download the MySQL Administrator here and MySQL Query Browser here. MySQL Administrator has powerful functions that allows you to manage/browse/backup your MySQL server/database in GUI. MySQL Query Browser is a replacement for MySQL Control Centre. It's a GUI-based program that allows you to test/execute your SQL queries. Install the MySQL Query Browser first before you install the MySQL Administrator.
    Isn't life's good when you do all the things just using your mouse ? =)

Voilà ~~~ ! There you go, everything should be working now. You shouldn't have any problem setup and run MySQL server. However, if everything goes that smooth, I wouldn't have to waste hours yesterday trying to figure out where it goes wrong. I can't get Apache to load PHP module, that's nasty and stupid problem.

Alright, If Apache says it can't load the php5apache2.dll or it says that the module can't be found then the below steps might save you... or not...

Another way to make Apache and PHP work together
  1. *Note* This section of guide assumes that you already install PHP. If not, please complete the steps in Installing PHP section before continue the steps below.
  2. *Updated 2007-01-17* On newer version of PHP (I tested with 5.2.0) you should able to find a DLL file name called php5apache2_2.dll. Now refering to Installing PHP - Step 7, change
    LoadModule php5_module "c:/php/php5apache2.dll"
    to:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    That should solved the problem and you can skip the steps below. If you're using older version of PHP build, please skip this step and follow the steps below.
  3. If you have Apache installed and you're stuck, uninstall it and remember to delete the folder manually for left overs (windows installer sometimes does not delete the config files, you need to clean it yourself). If you deploy Apache via a ZIP file instead of windows installer, you better do a httpd -k uinstall to uninstall the service then only you delete the folder manually.
  4. Download and install Visual C++ 2005 Redistributable Package from Microsoft. It can be downloaded at the link below:
    Microsoft
  5. Download httpd-2.2.3-win32-x86-ssl.zip (binary by Steffen) from Apache Lounge or use the direct link below:
    http://www.apachelounge.com/download/binaries/httpd-2.2.3-win32-x86-ssl.zip
    *Note* This binary is build with VC 2005, that's why you need Visual C++ 2005 Redistributable Package.
  6. The Apache binary is in ZIP file, there is no windows installer for this build. Unzip and place it to your C:\Program Files\Apache 2.2.3\
  7. Repeat the steps in Installing Apache section to configure your Apache server.
  8. Download php5apache2.dll-php5.1.x.zip from Apache Lounge or use the direct link below:
    http://www.apachelounge.com/download/mods/php5apache2.dll-php5.1.x.zip
  9. Unzip the file. Read the Readme First.txt.
  10. Copy & replace the php5apache2.dll to your php folder (eg. c:/php). Backup the original one if you feel to do so.
  11. Copy httpd.exe.manifest to /bin in your Apache folder.
  12. Open the httpd.conf file from /conf in your Apache folder. Look for ServerRoot and change the path to where you unzip the newly downloaded Apache binary. For example:
    ServerRoot "C:/Program Files/Apache 2.2.3"
  13. Scroll down and look for
    <IfModule alias_module>
    ...
    ...
    ...
    ScriptAlias /cgi-bin/ ...
    </IfModule>

    Make sure the ScriptAlias is set to the correct path. For example:
    ScriptAlias /cgi-bin/ "c:/Program Files/Apache 2.2.3/cgi-bin/"
  14. Scroll down and look for
    # "c:\..." should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "c:\...">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    </Directory>

    Make sure the <Directory> tag has the correct path. For example:
    <Directory "c:/Program Files/Apache 2.2.3/cgi-bin">
  15. Start your MySQL server and hit your Apache server. Your Apache should be able to load the php5apache2.dll now. For extra info, see also : http://www.apachelounge.com/forum/viewtopic.php?t=570

Hope this helps. By the way, I spent another 1/2 hr trying to locate another problem after I get the LAMP up (finally). The problem is that the raw source code of the PHP script is dumped out to my browser instead of excution output from the script. The cause of this problem is because one of the required php file starts with <? instead of <?php ... doh ! How strange, they worked in previous version of PHP5 I installed last time...

*EDIT 2006.08.30*
-- Hide the Visual C++ 2005 Redistributable Package actual link because the long url without spacing will not be wrapped by FireFox 1.5.0.6 during page rendering causing the page become "wide"

*EDIT 2006.09.19*
-- Added a how-to link to "Enable mod_rewrite in Windows"

*EDIT 2007.01.17*
-- Load php5apache2_2.dll instead of php5apache2.dll in newer version of PHP

Tutorial: PHP simple access control - 10:37 pm
Guides , PHP , Security  -  poster 

Found a great PHP tutorial written by Harry Fuecks on SitePoint that shows you how to build a site with access control. The tutorial focus mainly on user authentication, user permission and user registration that builds on solid foundation. The tutorial is not in depth but it is simple and easy to understand and it comes with codes that's practical. Suitable for beginners that needs a little bit more than simple security.

Link: The PHP Anthology Volume 2, Chapter 1 - Access Control

*Note* The tutorial uses example of database function class from The PHP Anthology Volume I, Chapter 3 - PHP and MySQL

PHP class constructor - 12:33 am
Bug , Coding , PHP , Security , Site Issue  -  poster 

I was doing some code clean up for my site and I found something interesting about the constructor in PHP class.

[ Hide ]
[ Highlight ] [ Text ]
  1. <?php
  2.  
  3. class Site
  4. {
  5. var $_DB;
  6. var $_User;
  7.  
  8. function Site()
  9. {
  10. $this->_DB = new DB();
  11. $this->_User = new User_Authentication();
  12. }
  13.  
  14. function process()
  15. {
  16. // some database access is needed in this function
  17. $this->_DB->query();
  18. }
  19. }
  20.  
  21. class DB
  22. {
  23. // ... some class implementation goes here ...
  24. }
  25.  
  26. class User_Authentication
  27. {
  28. var $_local_DB;
  29.  
  30. function User_Authentication()
  31. {
  32. // We reference to DB object in $SITE if exists,
  33. // otherwise we'll instantiate a new copy of DB locally
  34. if (isset($GLOBALS['mysite']->_DB))
  35. $this->_local_DB =& $GLOBALS['mysite']->_DB;
  36. else
  37. $this->_local_DB = new DB();
  38.  
  39. // A test if the global var $mysite exists or not at this point
  40. echo isset($GLOBALS['mysite']) ? 'Var $mysite is there' : 'The global var $mysite does not exist !';
  41. }
  42.  
  43. function process()
  44. {
  45. // some database access is needed in this function
  46. $this->_local_db->query();
  47. }
  48. }
  49.  
  50. // Let's run the test ...
  51. $mysite = new Site(); // this will be a global variable
  52. ?>

Finish digesting the code ? Let's focus on Line 10 & 11:
10.    $this->_DB = new DB();
11.    $this->_User = new User_Authentication();

... and line 34 - 37
34.    if (isset($GLOBALS['mysite']->_DB))
35.      $this->_local_DB =& $GLOBALS['mysite']->_DB;
36.    else
37.      $this->_local_DB = new DB();

So you would thought that the global var $mysite->_DB is created before the new User_Authentication class is called. As a result, when it comes to line 34, the statement will valid and thus statement on line 35 will be carried out.

But the truth is opposite. You run the script and the output will be The global var $mysite does not exist !.

Why? The key to the problem is on line 11
$this->_User = new User_Authentication();

Although $this->_DB is created after line 10, but that does not mean $mysite->_DB, or even $mysite is listed in PHP defined variable list at that time.

That's because everything happens inside the scope of Site class's constructor. Object are considered 'defined' or 'instantiated' once the script execution exits the class constructor.

That's a hidden surprise if you're not careful enough =O

PHP isset() - 7:40 pm
Bug , Coding , PHP  -  poster 

In PHP, sometimes you'll need to do alot of variable assignment like
[ Hide ]
[ Highlight ] [ Text ]
<?php
// simple
$bar = isset($foo) ? $foo : '';
// complicated
$bar = isset($foo[$test['index']]) ? $foo[$test['index']] : '';
?>


So I came up with this function to ease my life...
[ Hide ]
[ Highlight ] [ Text ]
<?php
// Use this to standardize things..
function isset_empty(&$input)
{
	return isset($input) ? $input : '';
}
?>


Things works fine at first. But later then I discovered that it's not working like what I expected when I pass a value inside an array to that function. See below:
[ Hide ]
[ Highlight ] [ Text ]
<?php
$bar = isset_empty($foo);  // $foo is undefined at this point
echo $bar;
$foo = array(1 => 'World', 2 => 'Cup');
print_r($foo);
$bar = isset_empty($foo[10]);
print_r($foo);
 
// The outpust result
//        <-- emptry string, expected
// Array ( [1] => World [2] => Cup )
// Array ( [1] => World [2] => Cup [10] => )
 
?>


It seems that index 10 with empty string is inserted to the $foo array after calling that function. It doesn't harm in some situation but it's a real disaster if you're using array to populate items or doing a count($foo) to check the array size. The results are affected !

So I have to replace all the statements that uses the function and go back to the old way

$bar = isset($foo[$test['index']]) ?$foo[$test['index']] : '';

Doh! glare

Simple PHP Blog - 6:38 pm
Coding , PHP , Website Intro  -  poster 

Just found a PHP blog project in SourceForge - Simple PHP Blog. It doesn't require a database, uses flat text files, and looked nice. Runs on PHP 4.

Looks simple and nice to me, but flat text file eh ?? I'm not really a big fan of it... imagine writing extra coding to process text file and performance degradation when you're dealing with large scale entries.

I haven't test the whole thing. But , it's not bad for short term blogging by just looking at their page though. Simple PHP Blog got the basic features like leave comment, trackback, permalink, search function, RSS feed and etc.

I'll check their admin control panel later on and study their code when I got enough time.

Visit their SourceForge project page, or their web page.

New design approach - 2:54 am
Coding , PHP , Site Issue , Site Updates , Standards  -  poster 

I'm updating my site again. I've been working on the core functions / classes. Yes, the CORE part... The major ones are like user authentication and database connection. I've unified all database access under one global variable, avoiding multiple DB connection objects created locally (class/function scope). The good thing about ? it saves memory and I can know how many SQL queries are made to construct a page. Scroll down to the very bottom and you can see how like "N queries made". Quite surprising though... some pages used like 35 SQL queries... o.O omg... gotna refine them later...

My current approach [ Hide ]
[ Highlight ] [ Text ]
-------site_management.php---------------
// The class of "everything", contains db connection
// and other authentication
class site_management
{
    var $DB_OBJECT;
    function site_management()
    {
        // Let's say MYSQL_DB is your class that contains
        // all functions to access/manipulate the database
        $this->DB_OBJECT = new MYSQL_DB();
    }
}
 
-------foo.php--------------------
// Some class that requires access to database
class foo
{
    // Internal database connection object
    var $_db_object;
 
    function foo()
    {
        // If global variable $SITE->DB_OBJECT exists, make reference
        // to it otherwise instantiate a new copy locally
        if (isset($GLOBALS['SITE']) && $GLOBALS['SITE']->DB_OBJECT)
            $this->_db_object =& $GLOBALS['SITE']->DB_OBJECT;
        else
            $this->_db_object = new MYSQL_DB();
    }
 
    function bar()
    {
        // You need to perform sql query here
        $this->_db_object->query($sql); // for example
        // ...
    }
}
 
------test.php-------------------
// The above two class is located in different files
// and below is also in a seperate script file
<?php
    $SITE = new site_management();
    $foo_obj = new foo();
    $foo_obj->bar();
?>


My old way [ Hide ]
[ Highlight ] [ Text ]
-------foo.php--------------------
// Some class that requires access to database
class foo
{
    // Internal database connection object
    var $_db_object;
 
    function foo()
    {
        // Instantiate a new copy locally
        $this->_db_object = new MYSQL_DB();
    }
}


Let me know what you think about this. You can also leave me a message here.

Read more about referencing global variable:
http://www.php.net/manual/en/language.references.whatdo.php
http://www.obdev.at/developers/articles/00002.html

In authentication part I removed ALL spaghetti-style-redirection when transfering a user through a login/logout. In short, no more hidden values inside <form> to track user, session is used instead. Clean code and it works! Hopefully things will work fine... even though I'm extremely carefully when touching the core part, because almost everything are built on top of it.

You should also have notice the "N visitor(s) online now" thing on the left navigation menu. Although most of the time there is only 1 visitor, me myself lol Talking about the navigation menu, I'm adding options to show/hide the menu with javascript. See that red button with a 'X' ? That's what I'm talking about.

Others updates are misc and minor updates in template/admin control panel.

Redirecting with PHP header() - 11:41 pm
Browser , Bug , PHP , Site Issue , Standards  -  poster 

On the redirection of shoutbox, I've made 2 mistake causing it unable to work on some browsers, example IE 6. In PHP, to do a redirection is very simple.

[ Hide ]
[ Highlight ] [ Text ]
header('Location: http://domain.com/index.php');

However, don't do this [ Hide ]
[ Highlight ] [ Text ]
header('Location: http://domain.com/index.php');
die();


It seems logical if you put a die() after header('Location'). But the truth is, NO you shouldn't ! It will screw your code !
Took me some time to notice the problem. Not sure about header('Refresh') though, I'm calling die() after header('Refresh') and it seems running without problem.

Also remember to use absolute URI for the header instead of relative URI. Browser like Opera accepts relative URI but IE and Firefox ain't too friendly to it. That's the 2nd mistake I've made.
Page 1 of 2   ( 17 entries , showing 1 - 10 )
    1 2 Next  
$ view_blog.php 2009.09.17 18:16:41 $
Lost? | XML/HTML sitemap | Contact
38.107.191.85 , 21 queries , 0.2325s
Gzip enabled , CSS compressed , JS compressed
Copyright © 2005-2009 Darren's Outpost