News:

CPG Release 1.6.28
added submissions from {406man}
cleaned up a few PHP (8.4) deprecations
fixed PHP deprecation in calendar
removed security vulnerability
(please upgrade when possible)

Main Menu

Help to make this small plugin work with 1.6.x

Started by FansCityEu, April 16, 2019, 02:16:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FansCityEu

A hostee of mine is using this small plugin to display latest albums updated but does not work with PHP 7.x and CPG 1.6.x, I have tried to make it work but I have been unabled to do so, it reports "unable to connect to database"

<?php
require_once(
'include/config.inc.php');
header("Content-type: application/x-javascript");

$connect = mysqli_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass'])
or die('Error connecting to the server');

$connect_db = mysqli_select_db($CONFIG['dbname'], $connect)
or die ('Error connecting to the database');

$resultado = mysqli_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 6", $connect)
or die('No albums found with this query');
                                        
echo 'document.write(\'';
if(mysqli_num_rows($resultado) == 0){
echo 'No albums created';
} else {
echo '<ul id="galbuns">';
while($row = mysqli_fetch_array($resultado)){
echo ' ';
$album_id = $row['aid'];
$subresult = mysqli_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 6");

if(mysqli_num_rows($subresult) == 0){
$album_img = "http://siteurl.com./galeria/thumbs/thumb_nopic.png";
} else {
while($subrow = mysqli_fetch_array($subresult)){
$album_img = "http://siteurl.com./galeria/albums/".$subrow['filepath'].'thumb_'.$subrow['filename']  .$subrow['datebrowse'];
                                                                                
}
}

echo '<li><div class="galtitul"><a href="http://siteurl.com./galeria/thumbnails.php?album='.$album_id.' ">'.$row['title'].'</a></div></li>';

echo '';
}
}

echo '</ul>';
echo '\');';

?>

ΑndrĂ©

Quote from: FansCityEu on April 16, 2019, 02:16:55 AM
it reports "unable to connect to database"

Are you sure it reports exactly that message?