Hi i am getting the following error and have no idea how to find the problem
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 on line 40 in /home/thehats1/public_html/uploader/main.php
<?php
@define ( 'NO_AUTH_CHECK', 1 );
require 'includes/commons.inc.php';
require 'includes/pub_settings.inc.php';
$tpl_main = new Template ( TPL_DIR . 'tpl_main.php' );
// for public uploader
$upload_max = get_byte_value ( ini_get ( 'upload_max_filesize' ) );
$post_max = get_byte_value ( ini_get ( 'post_max_size' ) );
$max_php_file_size = min ( $upload_max, $post_max );
$max_filesize = $PUB['max_file_size'] > 0 ? $PUB['max_file_size'] * 1024 : $max_php_file_size;
$restrictions = array
(
'max_file_size' => $max_filesize,
'allowed_types' => $PUB['images_only'] ? 'jpg,jpeg,gif,png' : $PUB['allowed_filetypes'],
'images_only' => $PUB['images_only']
);
$tpl_main->set ( 'restrictions', $restrictions );
// Get latest users
$new_users = array();
$new_user_limit = (int)$UPL['SETTINGS']['new_user_limit'];
$result = $mysqlDB->query ( "SELECT * FROM uploader_users ORDER BY userid DESC LIMIT $new_user_limit" );
if ( $result->error() ) exit ( $mysqlDB->error ( __LINE__, __FILE__ ) );
while ( false !== ( $user = $result->fetchRow('assoc') ) )
{
processUser ( $user );
$new_users[] = $user;
}
$result->free();
$tpl_main->set ( 'new_users', $new_users );
// get most popular
$popular = array();
$popular_limit = $PUB['popular_limit'];
$result = $mysqlDB->query ( "SELECT * FROM uploader_pfiles AS f LEFT JOIN uploader_puploads AS s USING(upload_id) WHERE f.file_isimage=1 AND s.upload_ispublic=1 ORDER BY f.file_views DESC LIMIT $popular_limit" );
if ( $result->error() ) exit ( $mysqlDB->error ( __LINE__, __FILE__ ) );
while ( false !== ( $file = $result->fetchRow('assoc') ) )
{
$set = $file;
processPublicFile ( $file );
processPublicSet ( $set );
$popular[] = array ( 'set' => $set, 'file' => $file );
}
$result->free();
$tpl_main->set ( 'popular_files', $popular );
// get latest files
$latest_limit = $PUB['latest_limit'];
$latest = array();
if ( $latest_limit )
{
$result = $mysqlDB->query ( "SELECT *, COUNT(file_id) AS image_count FROM uploader_puploads JOIN uploader_pfiles USING(upload_id) WHERE file_isimage=1 AND upload_ispublic=1 GROUP BY uploader_puploads.upload_id ORDER BY file_id DESC LIMIT $latest_limit" );
if ( $result->error() ) exit ( $mysqlDB->error ( __LINE__, __FILE__ ) );
while ( false !== ( $file = $result->fetchRow('assoc') ) )
{
// although $file contains both the set info and file info, we have to split them in case processPublicFile and processPublicSet
// generate the same array keys. Just a precaution.
$set = $file;
processPublicFile ( $file );
processPublicSet ( $set );
$latest[] = array ( 'set' => $set, 'file' => $file );
}
$result->free();
}
$tpl_main->set ( 'latest_files', $latest );
// get latest announcements
$latest_ann_limit = $UPL['SETTINGS']['new_ann_limit'];
$announcements = array();
$result = $mysqlDB->query ( "SELECT *, COUNT(comment_id) AS comments_count FROM uploader_announcements AS a LEFT "
. " JOIN uploader_usercomments AS uc ON uc.object_id=a.announcement_id AND uc.comment_type=" . COMMENT_ANNOUNCEMENT
. " GROUP BY announcement_id ORDER BY announcement_id DESC LIMIT $latest_ann_limit" );
if ( $result->error() ) exit ( $mysqlDB->error ( __LINE__, __FILE__ ) );
while ( false !== ( $ann = $result->fetchRow('assoc') ) )
{
$ann['view_url'] = UPLOADER_URL . ( MOD_REWRITE ? 'announcements?action=view&aid=' . $ann['announcement_id'] : 'announcements.php?action=view&aid=' . $ann['announcement_id'] );
$announcements[] = $ann;
}
$result->free();
$tpl_main->set ( 'latest_announcements', $announcements );
// get stats
$stats = array();
$result = $mysqlDB->query ( "SELECT SUM(file_size) AS size, COUNT(file_id) AS total FROM uploader_userfiles" );
$row = $result->fetchRow('assoc');
$stats['total_user_files'] = $row['total'];
$stats['total_user_size'] = $row['size'];
$result->free();
$result = $mysqlDB->query ( "SELECT COUNT(userid) AS total FROM uploader_users" );
$row = $result->fetchRow('assoc');
$stats['total_users'] = $row['total'];
$result->free();
$result = $mysqlDB->query ( "SELECT SUM(file_size) AS size, COUNT(file_id) AS total FROM uploader_pfiles" );
$row = $result->fetchRow('assoc');
$stats['total_public_files'] = $row['total'];
$stats['total_public_size'] = $row['size'];
$result->free();
$tpl_main->set ( 'stats', $stats );
// display all
$tpl_uploader->set ( 'content', $tpl_main, true );
?>