richard101000 Posted August 12, 2017 Share Posted August 12, 2017 Am trying to install an addon and I get the following error Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead The code is: if( pos_having ) $pos_shorter = 0; // Check if having is present in query else $pos_shorter = $pos_from; $finalquery = "select count(" . $count_string . ") as total, count($count_string) as cnt " . substr($this->sql_query, $pos_from, $pos_to-$pos_shorter); $result = mysql_query($this->sql_query) or die(mysql_error()); $matches = mysql_num_rows($result); $this->number_of_rows = $matches; Can anyone help please? Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted August 12, 2017 Share Posted August 12, 2017 This is the code changeset that will go into our next v2.3.5 release for PHP7 and MySQL 5.7 compatibility: https://github.com/osCommerce/oscommerce2/commit/5bc88b789fc7d92c7171dfc4812db21f53b33693#diff-37171063918967125379d5de7f238b7f If you apply the changes to your files, the php deprecated notices will be ignored and no longer show. , osCommerce Link to comment Share on other sites More sharing options...
richard101000 Posted August 12, 2017 Author Share Posted August 12, 2017 Thanks worked a treat! Shame i cant say the same about the addon! Link to comment Share on other sites More sharing options...
richard101000 Posted August 12, 2017 Author Share Posted August 12, 2017 Right so that got rid of that error but now when I click on a category it says: No database selected...Ive narrowed it down to that one change above which can be seen below, can anyone help? catalog/includes/classes/split_page_results.php Replace the following: $count_query = tep_db_query("select count(" . $count_string . ") as total " . substr($this->sql_query, $pos_from, ($pos_to - $pos_from))); $count = tep_db_fetch_array($count_query); $this->number_of_rows = $count['total']; with if( pos_having ) $pos_shorter = 0; // Check if having is present in query else $pos_shorter = $pos_from; $finalquery = "select count(" . $count_string . ") as total, count($count_string) as cnt " . substr($this->sql_query, $pos_from, $pos_to-$pos_shorter); $result = mysql_query($this->sql_query) or die(mysql_error()); $matches = mysql_num_rows($result); $this->number_of_rows = $matches; Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted August 12, 2017 Share Posted August 12, 2017 Try replacing the mysql_ prefix with tep_db_ prefix to use the actual OSCOM database functions. Calling mysql_* functions directly skips the configuration that the OSCOM database functions have set up. mysql_query() -> tep_db_query() mysql_error() -> comment the "or die(mysql_error())" part out mysql_num_rows() -> tep_db_num_rows() , osCommerce Link to comment Share on other sites More sharing options...
richard101000 Posted August 12, 2017 Author Share Posted August 12, 2017 Thanks I will give that ago in a little bit and let you know how it went! Link to comment Share on other sites More sharing options...
richard101000 Posted August 12, 2017 Author Share Posted August 12, 2017 That worked thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.