Cool MySQL to MySQLi Online Converter Tool

Created: August 1, 2017
Last Modified: August 14, 2018
Subscribe to Internet Tips and Tools Feed

Convert any php MySQL code into MySQLi code instantly. Paste your code in the box below and press "Convert". Please make sure that you have a backup of your code before you use the code provided by this converter. There are no guarantees.



Your converted mysqli code will appear in the box below:

Sea Breeze Computers Home Page

Copyright © 2017 by Jeff Baker


8/13/2018 - ver 1.2 - Bug Fix: A conversion of code like if (mysql_db_query($DBName, $Query, $Link)) was not converting to proper code. This has been fixed.

7/6/2018 - ver 1.1 - Changed conversion of MYSQL_NUM => MYSQLI_NUM to only convert if it is uppercase letters so that it will not convert mysql_num_rows to MYSQLI_NUM_rows.

08/01/2017 - ver. 1.0 - Cool MySQL to MySQLi Online Converter Tool created.

Back to
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 22 comments.

Displaying first 50 comments.

1. Posted By: David Hay - - July 6, 2018, 7:35 am
Hi! This mysql to mysqli converter is the best I have found around, thank you!

Just one small thing, mysqli_num_rows comes through as MYSQLINUM_rows which errors.
Thanks again for the cool tool.

2. Posted By: Jeff - - July 6, 2018, 4:28 pm
Hi David Hay,

You're welcome! Thanks for the information. I think I fixed the bug you were having. Would you like to test it again?


3. Posted By: aisiahmk - - July 18, 2018, 2:48 am
convert work for login but update database not work

4. Posted By: Jeff - - July 18, 2018, 4:09 am
I'm sorry, I don't know what you mean. Can you give us an example of the code you are trying to convert and what you are expecting the converter to do?


5. Posted By: aisiahmk - - July 19, 2018, 2:22 pm
Sorry already solve. My fault, not your converter. Your converter is the best.

6. Posted By: Jeff - - July 19, 2018, 4:46 pm
Hi aisahmk,

That is good to know. Thank you for the update!


7. Posted By: Kasper222 - - August 14, 2018, 3:47 am
Hi Jeff, thanks for making this converter. I'm lost with all of this stuff. I have old mysql and wanted to convert to mysqli. I ran my code but got an error that I don't know how to fix.

Original code:
$Query="DROP TABLE $TableName";
if (mysql_db_query($DBName, $Query, $Link)) { do some stuff

New output code:
$Query="DROP TABLE $TableName";
if (mysqli_select_db( $Link,$DBName);=mysqli_query( $Link, $Query)) {

That semi colon is causing an error. How do I fix this?

Thanks in advance!

8. Posted By: Jeff - - August 14, 2018, 6:26 am
Hi Kasper222,

I apologize for that. mysql_db_query was deprecated a long time ago and the converter is not handling the if statement properly. Hopefully, in the future I will be able to fix the converter to work properly with the if statement. In the meantime I think you can change the code to this:

$Query="DROP TABLE $TableName";
mysqli_select_db( $Link,$DBName); $result=mysqli_query( $Link, $Query));
if ($result) {


9. Posted By: Jeff D - - October 4, 2018, 9:45 pm
I can't believe how well this thing worked! I have used other ones in the past that didn't seem to work... I pasted all my code, and boom, hours of frustration saved, it just works. You have received a tip my friend, you are amazing...

I just spinned a new droplet, and it has all the new PHP and all that... been procrastinating on switching to the new MYSQLI because in the past it still worked even though it was deprecated... now it doesn't work so you gotta switch.


10. Posted By: Jeff - - October 5, 2018, 11:25 am
Hi Jeff D,

Thank you very much for the tip and the words of gratitude.


11. Posted By: Voklee - - October 29, 2018, 2:26 pm
Thanks for this great tool! I have converted a website today and it runs now fine on PHP 7.1. (was 5.4)

12. Posted By: Jeff - - October 30, 2018, 8:47 am
You are welcome! Thank you for the comment and letting us know the result.


13. Posted By: Naresh - - November 23, 2018, 6:30 pm
My website is - can you help me for upgrade my version 5.6 to 7.2

14. Posted By: Terry - - November 27, 2018, 11:38 pm
Thanks for making this tool public.

Have older script like to convert and has many files. Before starting, could you tell me the difference between:

Object oriented code | Procedural code

Not positive which to choose and hate to choose wrong one with all the files need to convert:)

Thank you again!

15. Posted By: Jeff - - November 28, 2018, 9:09 am
Hi Terry,

From what I have read, most programming is going in the direction of Object Oriented code. So if you start programming using Object Oriented Code then if you ever have to convert again, the code will be closer to the direction things are moving toward. So if you ever needed to update the database programming again in the future, Object Oriented programming would probably be what you would come across.


16. Posted By: Terry - - November 28, 2018, 12:48 pm
Thanks for explaining and advice Jeff.

Will take a closer look at options now that I have idea of the route to take:)

17. Posted By: Mads - - December 2, 2018, 12:59 pm
Thank you for this converter, helped me quickly find out where to touch up my code when webhost upgraded. and

18. Posted By: David - - December 7, 2018, 9:24 am
Saved me several hours of work, appreciate it. Tipped you guys $10, well deserved.

19. Posted By: Jeff - - December 7, 2018, 6:40 pm
Hi David,

You're welcome. Thank you for your suppport!


20. Posted By: kalchev - - December 21, 2018, 3:34 am
Very good tool! Just a laugh - everywhere, mysql connectin is called $ mysqli (and for instance, it's called $ conn) and must be searched and replaced manually. Just specify this explicitly, otherwise the scripts do not work.

21. Posted By: code flow - - December 24, 2018, 7:26 am
Hi Jeff

First of all, thanks for the great converter! I came across a piece of code that seems to have confused it, and thought I'd report it in case you'd like to fix it. Of course I can also simplify my code to the essentials, and then the converter works...

$nid=mysql_result ($_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1"),0);

mysqli_data_seek($_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1", ); $nid=mysqli_fetch_array($_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1")[0],0);

mysqli_data_seek($_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1", 0); $nid=mysqli_fetch_array($_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1")[0],0);

22. Posted By: Jeff - - December 24, 2018, 10:04 am
Thank you for reporting it. Sorry about that. The converter can't handle the nested functions. It only works with code like this:

$result=$_db->query("SELECT id FROM udb_tag_author ORDER BY Author ASC Limit 1");
$nid=mysql_result ($result,0);

Unfortunately, I don't think I will be able to fix it. I haven't looked at the code in a long time and in order to support nested functions I would have to overhaul not just those functions but many others. It would take a lot of time and research. Thanks again for reporting it though.