0

I read more than once that is better to use mysqli and than mysql.

I would like to know:

  1. I'm using WAMP for my local server and some share server for my online sites. what do i need to check on php.ini in order to be sure that mysqli will works?

  2. below is my db connection and query code. how would it looks like using mysqli?

$con = @mysql_connect ("localhost", "username", "pass"); 
if(!$con)
    exit("Unable to connect to the Database server");
    $db2 = @mysql_select_db("DB_NAME");
    if(!$db2)
        exit("Unable to connect to the Database");
    $query = mysql_query("SELECT somme_filed FROM some_table");
    while ($index= mysql_fetch_array($query ))
    {
        ....
    }
  1. most of my site was written in mysql. Do I really need to change all the code to mysqli? Is it really so important?
Dharman
  • 30,962
  • 25
  • 85
  • 135
Roi
  • 11
  • 2

1 Answers1

2

1.As long as you have only one instance of php installed there should not be any problem but if you have more than one instance you may need to point it manually to the version you wish to use. How do I activate mysqli with wampserver?

2.You can use mysqli to connect by doing something like this

$con = mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

3.MYSQL is no longer under development and has been considered deprecated. Why shouldn't I use MYSQL functions

nickzor
  • 84
  • 7