fife Posted February 1, 2011 Share Posted February 1, 2011 Hi. Right I'm trying to write a little script that selects one random image from a group and displays it on the page. Here is my code... $TheCat = $data['album_name']; $GetAPicy = "SELECT photo_name, album FROM photos WHERE album = '$TheCat' ORDER BY rand LIMIT 1"; $rGetAPicy = mysql_query($GetAPicy) or die(mysql_error()); $Picy = mysql_fetch_array($rGetAPicy); With this code I get the following error Unknown column 'rand' in 'order clause' Obviously I can see the error but I dont understand where they are supposed to be placed. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/226342-order-by-and-limits/ Share on other sites More sharing options...
salathe Posted February 1, 2011 Share Posted February 1, 2011 RAND() is a function and must be used as such, parentheses are needed. Quote Link to comment https://forums.phpfreaks.com/topic/226342-order-by-and-limits/#findComment-1168305 Share on other sites More sharing options...
fife Posted February 1, 2011 Author Share Posted February 1, 2011 perfect thank you Quote Link to comment https://forums.phpfreaks.com/topic/226342-order-by-and-limits/#findComment-1168306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.