Tag Archives: mysqli

Steps for converting mysql to mysqli

18 Jan , 2009,
Administrator
, ,
No Comments

As mysql and mysqli both belongs to same mysql server. mysql and mysqli as just modules provided with php.

when we started working on php and mysql then only mysql module was provided and different hosting company even not updated their mysql for latest version. so specifically we had to use the old technique to access these things. now many things are changing. People at the server company realize that they need to keep updated servers then only they will get more customer for their hostings. and now a days even customer are already known abt pros and cons of databases.

Now things begins here. now you have old traditional web site which was created using old techniques and you want to make things more optimised and go with new cutting edge technologies. so there few things which you really need to keep in mind that now a days different layers are used for web sites. its not as easy as what traditional methods. now on every front peoples are getting more advance. just for the sake of example. now for handling database there are dedicated peoples who knows clustering , memorycache ing for mysql. and in designing now advance flash version details are used with greate features. some templating used to keep site flexible to modify. and here we(Runwalsoft) have made all front details advance. each of our designer, programmer, database handlers are advance. they know how to tacles the hits. and how to mange more hits without losing their customers.

just for the sake of programmer. let say if you have used to open database connection you might have used.

$cn = mysql_connect('localhost','root','password') or die ('Unable to connect' . mysql_error());

which now you have to change like this.

$cn = new MySQLi('localhost','root','password','DatabaseName') or die("Unable to connect");

in the similar fashion you have to change queries as well previously we was using

$rs = mysql_query($sql,$cn) or die("Unable to find sql statement<br>" . mysql_error());

which is now

$rs = $mysqli->query($cn, $sql) or die("Unable to find sql statement <br>" . $mysqli->error);

I know that this is very very simple things but sometime people forgot how to use these. so I am writting this for newbie. mysqli means that mysql improved. and it having my good features along with it. I will update few more lines after some time. lets have start atleast. 🙂