Converting an old plugin that used mysql_query
-
Hello, I have an old plugin that I wrote long ago that used mysql with wordpress 2.9.1. I’m trying to update it to use wordpress 5.2 with PHP 5.6 installed.
My plugin did lots of sql queries, like this:
$query = mysql_query("SELECT testtable, testquestionpage, testincorrectpage, testanswerpage, testdonepage FROM wp_test_index WHERE id='" . $testid . "';");They’re now all returning false instead of the query result. This is with PHP 5.6, which should support both mysql and mysqli. I have a couple questions:
1) Do I need to convert from mysql to mysqli?
2) Do I need to supply the link_identifier (optional second argument) to mysql_query? I notice the wordpress code in wp-db.php tends to supply $this->dbh when making mysql functions, but I’m assuming that’s a private member of the wpdb class. Is there a way for me to get the database handle and use it in my plugin?
Thanks
The topic ‘Converting an old plugin that used mysql_query’ is closed to new replies.