Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter seanrice

    (@seanrice)

    OK, the following variation on the code works to do exactly what I wanted to do, but with the osCommerce database on the same server. That’s not always going to be the case. This issue is that I want to do this with the $wpdb instantiated class rather than straight php/mysql and I cant figure out what I’m doing wrong.

    THIS works:

    <?php
    function osccat_getlist() {
    global $wpdb;
    $category_list='';
    $sql = sprintf("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");
    $result = mysql_query($sql);
    if (!$result) {
        $message  = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $sql;
        die($message);
    }
    
    //$categories_query=$wpdb->get_results($sql);
    while ($categories = mysql_fetch_array($result)) {
    $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";
    mysql_free_result($result);
    return $category_list;
    }
    
    add_action('admin_menu', 'osccat_admin_actions');

    The OP code does not.

    Any love out there for me? ??

    Thread Starter seanrice

    (@seanrice)

    Obviously, the consistent problem that results in the error, “mysql_fetch_array() expects parameter 1 to be resource, array given in /home/gamestow/public_html/DEV/wp-content/plugins/rasa_osC_categories/osccat_admin.php on line 37” is a difference between what mysql_fetch_array expects and what it’s being given.

    I can do this with a direct connection to mysql, but I’d rather learn how I’m doing it wrong within the WP environment.

    I feel that I’ve done my homework and have gone through the forums both here and outside as well as the codex (which, btw, is singularly unhelpful with the subject of $wpdb)

    After staring at this, I just can’t figure out what’s wrong with the code. I’d appreciate some help. Thanks. ??

    Thread Starter seanrice

    (@seanrice)

    Sorry, BrightonPHP. That didn’t work. ??

    Thread Starter seanrice

    (@seanrice)

    Thanks. I was afraid of that, but where would I change it from within the database, itself?

Viewing 4 replies - 1 through 4 (of 4 total)