Hmm I'm not sure what I'm doing wrong.
Here's the code:
$sql = "SELECT COUNT(*) as total_images
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id=2
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."<br>
";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];
mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id=2
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."<br>
LIMIT $number, 1";
and here's the error:
DB Error: Bad SQL Query: SELECT COUNT(*) as total_images FROM 4images_images a, 4images_categories b WHERE a.image_active=1 AND a.cat_id=2 AND b.auth_viewcat=0 AND b.auth_viewimage=0<br>
You have an error in your SQL syntax near '' at line 7
DB Error: Bad SQL Query: SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments FROM 4images_images a, 4images_categories b WHERE a.image_active=1 AND a.cat_id=2 AND b.auth_viewcat=0 AND b.auth_viewimage=0<br> LIMIT 0, 1
You have an error in your SQL syntax near 'LIMIT 0, 1' at line 7
:
-Tim