PHP Basics

Why do web developers prefer MySQLi over MySQL in PHP Scripting?

Professionals, php Gurus and developers strictly suggest to use mysqli functions in php script. But while developing php application we have witnessed mysql function is working fine in script with latest version of php. Then why we should we go for mysqli functions.

MySQL functions in PHP

mysql functions in php are the old functions that are used to access, modify data in the mysql database using php code. But since php 5.5 version, mysql functions are deprecated. No future version of these functions is going to available from php.

It means, recent php versions going to run mysql function with out any error but in near future it wont work any more. We are bound to use mysqli functions.

MySQLi functions in PHP

Mysqli functions are the functions that are available by PHP to access or modify data in the mysql table. Mysqli is latest technology embedding all major security features.

Difference Between mysql and mysqli

Following are the difference between mysql and mysqli function.

  • mysql is old version and mysqli is the latest version
  • mysql deprecated in php 5.5 version but mysqli added in php 5.5 version
  • mysql does not support prepare statement while mysqli supports prepare statement
  • mysql provides only procedural procedure but mysqli provides both object oriented and procedural procedure.

If not today, then tomorrow we are bound to use mysqli functions irrespective of the benefits of mysql functions.

Thats why we must use mysqli functions over mysql functions while scripting in PHP.