Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, May 10, 2012

PHP - get full URL

There are times when we want to get the full path (URL) of a page, PHP makes it easy

function getPageURL() {
    $pageURL = 'http';

        // Check if https is enabled
    if ($_SERVER["HTTPS"] == "on") {
        $pageURL .= "s";
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
 
    return $pageURL;
}

Call getPageURL() whenever you want to get the expected path.

Friday, January 16, 2009

backup and restore mysql in ubuntu

although i use ubuntu with shell, you can use whatever linux's distribution, command should like the same

backup mysqlmysqldump -u [username] -p [password] [database'name] > [backup'sname]
exp: mysqldump -u root -p 123 mysite > mysite.bak.sql


restore from file backup
mysql
-u [username] -p [password] [database'name] < [backup'sname]

note that the only different is mysql <> mysqldump and >
<> <exp: mysql -u root -p 123 mysite < mysite.bak.sql
click here for more details

happy coding!