Archive for 2012

MySQL database export to pdf using PHP

 
To export whole database or whole table content we can use phpMyAdmin Export option but if you want to export some rows or any query result then we should perform some other way.
 
To create PDF file we should first download the FPDF Library – Click Here.
 
Copy the following code and create a new PHP file called exportpdf.php and paste the content into it or download the file – Click Here
 
Sample Output

Export PDF

Sample Code
 
<?php
require('fpdf.php');
$d=date('d_m_Y');
 

Read more »

How to fix ereg and ereg_replace is deprecated errors in PHP 5.3

 
If you upgraded to PHP 5.3 Version, chances are high you’re going to run into a few warnings or deprecated function error messages.
 
ereg is deprecated
 
An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.


 
To migrate ereg() to preg_match()
 
Before
 
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
 
After
 
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
 
Notice that we should wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.


Read more »

How To Optimize Your Site With GZIP Compression

 
Step 1
 
First you need to access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.
 

Add Leverage Browser Caching 1


 
Step 2
 
Open up your .htaccess file and paste the following lines.
 

Read more »