Jump to content

[SOLVED] using variable as limit


severndigital

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/112320-solved-using-variable-as-limit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.