Jump to content
Sign in to follow this  
TAV1702

SQL Off Topic Question [SOLVED]

Recommended Posts

Ok all you sql gurus, I have an issue I need a hand with.

First off, I must confess how much I SUCK at sql statements and trying to debug errors. This one is throwing errors. You probably see it but I don't. Have any clues? if so I should am all ears and willing to listen/read. I been banging my head on this part of the night.

$sql = "SELECT username, user_id, user_posts, user_avatar, user_avatar_type, user_allowavatar
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . "
ORDER BY user_posts DESC LIMIT " . $portal_config['md_total_poster'];
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
}

Here is the exact error word.

General Error

Could not query users

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4

SELECT username, user_id, user_posts, user_avatar, user_avatar_type, user_allowavatar FROM phpbb_users WHERE user_id <> -1 ORDER BY user_posts DESC LIMIT

Anyhow, here it is in all its glory. this has nothing to do with phpvms I just needed some insight so I figured I would toss it in off topic talk.

Thanks for taking a look.

Edited by TAV1702

Share this post


Link to post
Share on other sites

It doesn't look like

$portal_config['md_total_poster'];

is printing out anything. Did you spell that right? Try to echo it to debug it.

Should compile if

ORDER BY user_posts DESC LIMIT " . $portal_config['md_total_poster'];

is replaced to

ORDER BY user_posts DESC LIMIT 5";

The syntax looks right. It's gotta be some misspelling somewhere.

Edited by magicflyer

Share this post


Link to post
Share on other sites

Ahhh it did not register with me until you posted and I read it with my own eyes. You got it right on your first try. It was the

$portal_config['md_total_poster'];

I never even noticed but that option was removed from the version of software I upgraded to. DOH!!! :blink: That is why my query was failing. Well, part of the reason. It still has a syntax error but now I know it isn't even worth my time as that total poster option is removed.

Thanks for taking a look man I appreciate it.

Essentially what that little option was is a config option in the admin control panel to tell a block on home page how many top forum posters to show in a block. Well, the top posters option was removed in the upgraded version. I would say it is to save sql querys on the server which would be ridiculous as it is only 5 querys compared to the dozens that are ran when people are online using country and state flags.

Edited by TAV1702
  • Like 1

Share this post


Link to post
Share on other sites

The code was correct, the function was removed from the cms. I had no idea until i got to looking. I was trying to make a function run that no longer existed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×