views:

27

answers:

1

Hello

I'm creating a plugin for wordpress that'll require a couple of custom template tags for theming purposes.

At the moment I have this function:

function gs_subscribe_button ($type) {
    echo "alert";
    global $wpdb;
    $table_name = $wpdb->prefix . "subscription_types";
    $result = msql_query ("SELECT * FROM $table_name WHERE id = $type");
    while ($row = mysql_fetch_array($result)) {
        print_r($row);
    }
}

Which I assumed I could call from the theme template as with any core template tag. I know the file this function is in is being called as echo statements work outside functions.

However I can't seem to get any prints or echos from within the function. This is how I'm calling the function:

<?php gs_subscribe_button ("1"); ?>

Just incase thats wrong somehow.

solved it myself. Typo in the function!

A: 
$result = msql_query ("SELECT * FROM $table_name WHERE id = $type");

Should be:

$result = $wpdb->query("SELECT * FROM $table_name WHERE id = $type");

I do not think your "msql_query" is connected or open.

You should change it and use the $wpdb->query() or better yet $wpdb->get_results()

You should look into this class that Wordpress automatically creates for you. Extremely helpful!

Anraiki