Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
772 views
in Q2A Core by

Hi, I am playing a bit on a local install of Q2A (latest version) and have problem with the function qa_db_single_select from qa-db.php

I am basicly trying to implement an example submitted several time here, which is about returning in the sidebar the most active users. It is failing at:

foreach ($selectspec['columns'] as $columnas => $columnfrom) on qa-db with the following error:

"Warning: Invalid argument supplied for foreach() on line...(above line) ... SELEC FROM Error 1064: You have an error in your SQL syntax;..."

My qa-theme.php uses the following function (copied from another post):

function sidebar()
        {
            global $qa_db;

            qa_html_theme_base::sidebar();

            $users=qa_db_single_select($qa_db, qa_db_top_users_selectspec(0));
            echo "Most active";  
            foreach (array_slice($users,0,10) as $user)
                $this->output('<P>'.qa_get_one_user_html($user['handle'], false).
                    ' ('.number_format($user['points']).')</P>');
        }

Any idea?

by
I am getting the same error when i try this code

1 Answer

+2 votes
by
Version 1.3 removed the need for the $db (or $qa_db) parameter from almost every function where it appeared, so you can get rid of it from qa_db_single_select(...) and also no longer need to retrieve it via the global line.
by
edited by
Great worked perfectly. But just a little question how do i add avatars to this? and title if possible?
by
@Tenac, could You please publish the changed code here ?
Thanks, monk333
by
@monk333:


function sidebar()
        {
   
    qa_html_theme_base::sidebar();

    $users=qa_db_single_select(qa_db_top_users_selectspec(0));
    echo "<b>Most Active</b>";  
    foreach (array_slice($users,0,5) as $user)
    $this->output('<P>'.qa_get_one_user_html($user['handle'], false).
     ' ('.number_format($user['points']).')</P>');
    
    }
by
Thank You, saves me and others some time..

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...