what wrong with my code? what wrong with my code?
 

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]

Main Menu

what wrong with my code?

Started by Hot Rides, August 09, 2008, 03:39:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hot Rides

why does this code not exclude albums with an id higher than 10000


$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid > 9999 ORDER BY RAND() LIMIT $limit";


or am I way of base?

Nibbler

Because you are requesting that the aid is larger than 9999. If you want only ones less than 10000 then use '< 10000'.

Hot Rides

but its not limitng the search at all, its still showing all albums

Nibbler


Hot Rides

www.hot-rides.net/forum
its the slider at the top, it pulls 30 random images from all albums, with user generated pics only making up about 1% of all files its hard to tell

Hot Rides

i did some testing with lower numbers and it seems to be working now, I guess I have to just wait and see if it pulls from any user albums

Nibbler

User albums are those with a category over 10000, you can't filter them out by looking at the aid.

Hot Rides

all user created albums are 10000+, if I limit the string to 9999 or less it will effectivly filter out all user generated albums and the pictures inside them. My ultimate goal is only to filter private albums but I dont know the code well enough

Hot Rides

edit, I see what you mean nibbler, im a fool, can I just use 'cat <9999' instead?

Nibbler

No, since the category is a property of the album not the picture. To filter out user albums:


$query = "SELECT p.* FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' AND category < 10000 ORDER BY RAND() LIMIT $limit";


To display only 'visible to everyone' albums:


$query = "SELECT p.* FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' AND visibility = 0 ORDER BY RAND() LIMIT $limit";


Hot Rides

thank you for the help Nibbler, Im sure these to lines of code will help me more in the future too.