can anyone please explain what is the difference between mysql() and mysqli().
and which is best to use in projects for best performance…
Mysqli can be done procedural and object-oriented whereas mysql can only be used procedurally (without adding your own wrapper class). Mysqli also supports prepared statements which protect from SQL Injection.
An example of the different ways you can write mysqli: http://uk1.php.net/manual/en/mysqli.quickstart.dual-interface.php
Really you have no excuse not to use mysqli so go for it.
An extensive overview of MySQL vs MySQLi (vs PDO) can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
The most important thing to note is that mysql is deprecated, and should not be used for any new development, as pointed out on the site above.
ScallioXTX beat me to it, but yes. MySQL is the old library and now is deprecated. Please use the new MySQLi library. It’s fairly the same, except the coding is different. You still have the excapes, fetches, whiles, if statements, .etc. It’s just a more secure library than the old MySQL. Everyone recommends PDO, but if you’re used to MySQL, you can choose MySQLi too.
It’s up to you to choose what you wanna use, but don’t use the old libraries because it’ll probably not be safe.