severndigital Posted June 28, 2008 Share Posted June 28, 2008 can this be done? if so, i can't seem to figure it out. using this query mysql doesn't like it. $limvar = 3; $sql = "SELECT * FROM table WHERE used='0' ORDER BY RAND() LIMIT '$limvar'"; $pull = mysql_query($sql)or die(mysql_error()); when i run this query i get an error saying my syntax is wrong near "3" on line 1 if i run the exact same query but replace '$limvar' with the number 3 .. everything works perfect. any ideas?? Thanks, C Quote Link to comment Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 $limvar = 3; $sql = "SELECT * FROM table WHERE used='0' ORDER BY RAND() LIMIT $limvar"; $pull = mysql_query($sql)or die(mysql_error()); I would try $limvar with out the speech marks around it as it's an integer and doesn't need these. Quote Link to comment Share on other sites More sharing options...
severndigital Posted June 28, 2008 Author Share Posted June 28, 2008 That worked perfectly .. thanks. Quote Link to comment 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.