Convert and update from mysql to mysqli

You should know about php and why it is best to use.


In PHP5 PHP7 mysql is depreciated so you have to convert program to mysqli.
Basic changes in converting is


MYSQL

 mysql("localhost""my_user""my_password");


MYSQLI

$mydb =  mysqli("localhost""my_user""my_password", "Database_name");

You can check weather connection is establised or not.

if($mydb){
 echo 'Database connection establised';
}

else {
    printf("Connect failed: %s\n"$mysqli->connect_error);
    exit();
}

In addition to the above change you also have to change in the query that is used to insert/update/fetch data from Database.

$insert_from=mysqli_query($mydb,"insert into contactus (name,mobile)  values ('user','123')");

if($insert_from){
 echo 'Query excuted sucessfully';
}





Share this

Related Posts

Previous
Next Post »