CSS for Box Shadow

div {
box-shadow: 10px 10px 5px #888888;
}

Posted in CSS | Leave a comment

Backup All of your MySQL Databases using AutoMySQLBackup

If you have a WHM account and manage several accounts/websites under it, taking a backup of ALL of the MySQL Databases get simplified with AutoMySQLBackup.

Here is how to go:

Download a copy of AutoMySQLBackup from http://sourceforge.net/projects/automysqlbackup/

Automatic Installation
1. Unzip and Upload the folder you downloaded on your Server and run the install.sh script. Simply type sh install.sh in the command line. The installation will proceed.
2. Edit the configuration file located at /etc/automysqlbackup/myserver.conf to customize your settings.

Manual Installation
1. Unzip the file you downloaded.
2. Create the /etc/automysqlbackup directory.
3. Copy in the automysqlbackup.conf file.
4. Copy the automysqlbackup file to /usr/local/bin and make executable.
5. Copy /etc/automysqlbackup/automysqlbackup.conf /etc/automysqlbackup/myserver.conf
5. Edit the /etc/automysqlbackup/myserver.conf file to customize your settings.

How to Run AutoMySQLBackup?

Running through Command Line : Just type in automysqlbackup in the command line and you are all good! If you see any error in the screen, perhaps there is something wrong with your config file.

Running as Cron Job : Add the following line to your cron file
57 11 * * * /usr/local/bin/automysqlbackup
This will run AutoMySQLBackup every day at 11:57 AM

 

Posted in Linux, MySQL | Leave a comment

Compress a Folder in Linux using Command line

To create a .gz archive of a directory and its sub-directories
tar -cvzf filename.tar.gz directory_to_compress/

To extract the compressed file, replace -cvzf with -xvzf

To create a .zip acrhive
zip -r filename.zip folder_to_zip

Posted in Linux | Leave a comment

Centre Aligning ul with fluid width using css

If you have your site navigation in ul, li elements and seeking to center align the items to the center of the screen, here is the quick css for that

ul.nav{
list-style-type:none;
margin:0 auto;
display:table;
}

ul.nav li{
list-style-type:none;
display:table-column;
float:left;
}

 

Posted in CSS | Leave a comment

Import Excel File into MySQL Database using PHP

You can easily import your data from any Excel file into MySQL Database using a simple PHP script and PHPExcelReader library.

Steps to Import Excel file data into MySQL using PHP Script

1. Download the following library

PHPExcelReader – http://sourceforge.net/projects/phpexcelreader/

2. After you have downloaded the files, please upload them to your web server.  To work around a small bug in PHPExcelReader, copy oleread.inc file from the Excel directory into a new path: Spreadsheet/Excel/Reader/OLERead.php

The PHPExcelReader code will expect OLERead.php to be in the above specific location. Once that is complete, you’re ready to use the PHPExcelReader class.

setOutputEncoding('CP1251');
$data->read('your-excel-file.xls');

$conn = mysql_connect("dataBaseHostName","DataBaseUserName","DataBasePassword");
mysql_select_db("DataBaseName",$conn);

for ($x = 2; $x < = count($data->sheets[0]["cells"]); $x++) {
    $name = $data->sheets[0]["cells"][$x][1];
    $email = $data->sheets[0]["cells"][$x][2];
    $phone = $data->sheets[0]["cells"][$x][3];
    $sql = "INSERT INTO mytable (name,email,phone) 
        VALUES ('$name',$email,'$phone')";
    echo $sql."\n";
    mysql_query($sql);
}
?>
Posted in General | Leave a comment