Yet another "mysql_fetch_array() expects parameter 1 to be resource" issue…
-
Yeah, I know, there’s a ton of posts on this and I believe I’ve read all of them, or as many as I could find. I’ll try to give all the information needed to solve this: After 2 days, I’m completely stuck.
(1) I was trying to do a variation on a plug-in tutorial for integrating osCommerce and WordPress by getting random product images to show in the side bar. The url of the tutorial is http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/
(2) He was trying to get random product pics and links to show in sidebar. I’m trying to get osCommerce categories to show in the sidebar so that the WP and osCommerce match on the left column.
(3) Based on the tutorial (and based on not knowing if the osCommerce database will always be on the same server) I did most of the tutorial, then borrowed the SQL query almost directly from the box module (in English) from osCommerce. The SQL query works outside of WP, but not here. I even tested to make sure that the query was actually returning results and it is.
<?php function osccat_admin() { include('osc_category_admin.php'); } function osccat_admin_actions() { add_options_page("OSCommerce Category List", "OSCommerce Category List", "manage_options", "oscommerce-category-list", "osccat_admin"); } function tep_db_fetch_array($db_query) { return mysql_fetch_array($db_query, MYSQL_ASSOC); } function osccat_getlist() { global $wpdb; //Connect to the OSCommerce database $oscommercedb = new wpdb(get_option('osccat_dbuser'),get_option('osccat_dbpwd'), get_option('osccat_dbname'), get_option('osccat_dbhost')); $category_list=''; $categories_query = $oscommercedb->get_results("select c.categories_id, cd.categories_name, c.parent_id from categories c, categories_description cd where c.parent_id = '0' and c.categories_id = cd.categories_id order by sort_order, cd.categories_name") or die(mysql_error()); print_r($categories_query); while ($categories = mysql_fetch_array($categories_query, MYSQL_ASSOC)) { $category_list.='<li><a href="storeindex.php?osCsid=' . $categories['categories_id'] . '">' . $categories['categories_name'] . '</a></li>' . "\n"; } $category_list='<ul>' . "\n" . $category_list . '</ul>' . "\n"; return $category_list; } add_action('admin_menu', 'osccat_admin_actions'); ?>Trying to insert code for the first time, so…
Modifications are mostly about trying to pinpoint the error..
The topic ‘Yet another "mysql_fetch_array() expects parameter 1 to be resource" issue…’ is closed to new replies.