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? 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. 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 Link to comment https://forums.phpfreaks.com/topic/226342-order-by-and-limits/#findComment-1168306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.