Hi..
I'm having problem with my website, and I just cannot figure it out what's the problem with my code. Any ideas?
Thanks.
// get related files from database
if ($settings['related_files'] == 1) {
$related_query = mysql_query('SELECT f.fileid, f.title, f.description, f.icon, f.iconlocation, f.timesplayed from '. $tbl_prefix .'related AS r JOIN '. $tbl_prefix .'files AS f ON (f.fileid = r.related_id) WHERE r.file_id = '. $file['id'] .' LIMIT '. $settings['max_related_files']);
// find new related files
if (mysql_num_rows($related_query) == 0 && strpos($file_row['keywords'], " ") !== false) {
mysql_free_result($related_query);
$related_query = mysql_query("SELECT fileid, title, description, icon, iconlocation, timesplayed
FROM ". $tbl_prefix ."files USE INDEX (search)
WHERE MATCH(title, description, keywords) AGAINST('". escape_string(str_replace(',', '', $file_row['keywords'])) ."') AND status = '1' AND fileid != ". $file['id'] ." LIMIT ". $settings['max_related_files']);
$save_related = true;
} else {
$save_related = false;
}
$txt['related'] = array();
while ($related_row = mysql_fetch_assoc($related_query)) {
$txt['related'][] = array (
'id' => $related_row['fileid'],
'title' => $related_row['title'],
'url' => fileurl($related_row['fileid'],$related_row['title']),
'description' => shorten_description($related_row['description']),
'image' => file_image_url($related_row['icon'], $related_row['iconlocation']),
'played' => $related_row['timesplayed']
);
}
mysql_free_result($related_query);
$settings['related_files'] = !empty($txt['related']); // do not show if empty
// save found related files
if ($save_related && $settings['related_files']) {
$related_sql = array();
foreach ($txt['related'] AS $val) {
$related_sql[] = '('. $file['id'] .', '. $val['id'] .')';
}
mysql_query('INSERT INTO '. $tbl_prefix .'related (file_id,related_id) VALUES '. implode(',', $related_sql));
}
}