Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Search Function is usermgr.php (sql error)  (Read 2491 times)

0 Members and 1 Guest are viewing this topic.

terrorhawk

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Posts: 61
Search Function is usermgr.php (sql error)
« on: April 13, 2005, 08:32:45 pm »

Hello.
i'm trying to build a search function in the userlist created by usermgr.php

but i looks like i cant use WHERE user_name LIKE or WHERE u.user_list LIKE
here is my code i use
Code: [Select]
    $search = $_GET['search'];

$sql = "SELECT user_id, user_name, UNIX_TIMESTAMP(user_regdate) as user_regdate, UNIX_TIMESTAMP(user_lastvisit) as user_lastvisit, user_active, ".
           "COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage, group_name, group_quota ".
           "FROM {$CONFIG['TABLE_USERS']} AS u ".
           "WHERE u.user_name LIKE " . $search . " ".
           "INNER JOIN {$CONFIG['TABLE_USERGROUPS']} AS g ON user_group = group_id ".
           "LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.owner_id = u.user_id ".
           "GROUP BY user_id ".
           "ORDER BY " . $sort_codes[$sort] . " ".
           "LIMIT $lower_limit, $user_per_page;";

i want to use %$search% but i first i have to make this one work

there error is like this

Code: [Select]
While executing query "SELECT user_id, user_name, UNIX_TIMESTAMP(user_regdate) as user_regdate, UNIX_TIMESTAMP(user_lastvisit) as user_lastvisit, user_active, COUNT(pid) as pic_count, ROUND(SUM(total_filesize)/1024) as disk_usage, group_name, group_quota FROM cpg11d_users AS u WHERE u.user_name LIKE 'terrorhawk' INNER JOIN cpg11d_usergroups AS g ON user_group = group_id LEFT JOIN cpg11d_pictures AS p ON p.owner_id = u.user_id GROUP BY user_id ORDER BY user_regdate DESC LIMIT 0, 25;" on 0

mySQL error: 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 'INNER JOIN cpg11d_usergroups AS g ON user_group = group_id LEFT

it keeps getting error in INNER JOIN

can someone please help me and tell me how to add this line in the sql query ?
couse a search function in a user list with 1500+ users would be great :P
and i'm almost there

Grz
Logged

Nibbler

  • Guest
Re: Search Function is usermgr.php (sql error)
« Reply #1 on: April 13, 2005, 10:28:55 pm »

This is already a feature of the next version so you can see how it is implemented there in the CVS, but basically the WHERE needs to go after the join. Check the MySQL manual (as suggested ;))
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.