coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: JohanX on May 07, 2006, 12:06:30 PM

Title: Fetch some data from MySQL
Post by: JohanX on May 07, 2006, 12:06:30 PM
Hi,
I want to fetch the last picture posted to coppermine and for that i made this code, but it doesn't seem to work.. I saw in coppermine code that it uses a special function to connect to mysql but the include and require functions are so many that i get lost searching for the right thing
The code that i made : <?php
// MySQL configuration
$dbserver ='******';        // Your database server
$dbuser =  '******';        // Your mysql username
$dbpass =  '******';                // Your mysql password
$dbname =  '******';

$conex mysql_pconnect($dbserver,$dbuser,$dbpass) or die('Can\'t connect !');
mysql_select_db($dbname,$connex);
$result mysql_query("SELECT * FROM cpg145_pictures ORDER BY pid DESC LIMIT 1");
$row mysql_fetch_array($result); 
$w $row['pwidth'];
$h $row['pheight'];
$fixedw 110;
$fixedh 110;
if ($w>$h) {
if ($w>$fixedw) { $w $w $fixedw;
  $am = ($w/$t)*100;
  $h $h - (round(($am*$h)/100));

} elseif ($h>$fixedh) { $h $h $fixedh;
    $am = ($w/$t)*100;
    $w $w - (round(($am*$w)/100));






echo
'
<strong>Last adition</strong> <br />
<img border="0" src="cm/'
.$row['filepath'].$row['filname'].'" width="'.$w.'" height="'.$h.'" alt="'.$row['title'].'" title="'.$row['title'].'" /> <br/>
<p>'
.$row['title'].'</p>';  
?>


ignore the resizing part.. just the array fetching i'm interested in. it doesn't give a connection error but it doesn't show anything if I call mysql_query('Show tables');
Thanks,
Johan
Title: Re: Fetch some data from MySQL
Post by: Joachim Müller on May 07, 2006, 03:39:12 PM
http://forum.coppermine-gallery.net/index.php?board=57.0