mysql to mysqli conversion

If you used an older version of PHP and switched to PHP7, and now all your msyql  commands are failing, you should be able to use the following to fix it. You’ll have to run it in every directory where you have php files, of course.

sed -i 's/mysql_query(\([^,()]*\),\([^,()]*\))/mysqli_query(\2,\1)/g;'\
's/mysql_connect/mysqli_connect/g;'\
's/mysql_select_db(\([^,()]*\),\([^,()]*\))/mysqli_select_db(\2,\1)/g;'\
's/mysql_f/mysqli_f/g;'\
's/mysql_e/mysqli_e/g;'\
's/mysql_numrows/mysqli_num_rows/g;'\
's/mysql_n/mysqli_n/g' *.php

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.