Posts Tagged ‘Php’

BigDump – Restore Large MySQL Dump Files

BigDump is one of the commonly used php scripts which comes in handy if you are to import a larg .sql file. The conditions unders which it proves to be useful are:

  • You dont have access to server’s shell (command prompt).
  • You dont have PhpMyadmin available.
  • Your webserver and php configuration dont allow the upload of max file sizes.

Running this script is pretty easy. simply download it, unzip it, ftp into your website and upload this bidump.php file. Once upload is complete, open it and set the DB Name, Username and Password of your mysql server and the database you are going to import it. Once done, save this file and open it in web browser as http://yourdomain.com/bigdump.php (offcourse you will need to replace yourdomain.com with the name of your domain).  Here you will be presented with an interface to upload .sql file and import it.

Okay, That’s it, now you can upload and restore large database dump file without any worry. Cheers! :)


PHP-mysqlnd Is Native MySQL Driver For PHP

Lets see how PHP and MySQL works together. Here is the list of three extensions which PHP uses to connect to MySQL.

mysql
mysqli
pdo mysql

All of the above mentioned extensions are rely on MySQL’s client library libmysql. Mysqlnd is an another and  alternative way of connecting  PHP 5 and PHP 6 to the MySQL Server. Now the question arises why use Mysqlnd instead of other extensions ?

Here is the list of advantages of Mysqlnd library over other mentioned extensions.

  • It is very easy to compile, it does not have any dependencies issues with mysql client programming support.
  • It performs much better then libmysql in certain cases.
  • It provides persistent connections for mysqli.
  • It key feature is that it uses PHP memory management and it supports PHP memory limit.
  • It is famous for reducing memory footprint because it stores every row only once in memory while in the case of libmysql  it  is saved twice in memory.

Cheer!

PHP Fatal Error: Call To Undefined Function Json_encode()

I just run into a problem, I deployed my php application on one of the production sever and a link started throwing the error PHP Fatal error: Call to undefined function json_encode()in the apache error logs. Here is what I did to fix it.

The code was working fine on my localhost machine because the local machine contained php of version 5.2.4 and php versions greater than 5.2 have json module built in. But on my production sever, Php version was 5.1.6. It was hactic process to upgrade the php version on non managed server.

Dont go around, the module can easily be installed via Pecl Module. But for Pecl module, its necessary that pear should be already present on your server. Install Pear Library with the following command:

yum install php-pear

Once the installation is over, you are ready to rock, run the following command to install json.

pecl install json

Once the installation is over, you will find json.so file located in you php modules directory. Normally php modules directory is /usr/lib/php/modules. Once you are sure that this module is available, simple add the following line to you /etc/php.ini file.

extension=json.so;

Now dont forget to restart apache service.

service httpd restart

Type php -m and you will find json loaded along with other modules of the php. Now your code will also work fine. Cheer!

How To Install Symfony On Linux

Symfony is the collection of classes written in PHP and it is the most commonly used PHP Framework. Here are the steps to install it in Linux ( The following instructions should work on all Linux distros, I followed them on Fedora Core).

First of all make sure that Pear is already installed, open the terminal and download the go-pear file by running the following command:

wget http://pear.php.net/go-pear

Once the go-pear is downloaded, run the following command to install Pear to your system.

php go-pear

Then follow the onscreen instructions and you are done with the Pear installation in some time. Once the Pear installation is completed, then it is the piece of cake to install symfony. ( Sometimes symfony may also require the ‘dom’ extension to be loaded).

» Read more