forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: grantson on June 24, 2010, 11:59:44 am
-
Been reading the documentation & searching the board and through the core files all morning trying to find out how the array $Current_pic_data is populated
If i pass the pid in a url to another page within my site how do i then use the pid to gather the rest of the pic info
-
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616
-
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616
using a gallery installed on a virtual test server...
but
www.magicmirrorphoto.co.uk/gallery
-
If i pass the pid in a url to another page within my site how do i then use the pid to gather the rest of the pic info
With a simple SQL query like
SELECT * FROM cpg15x_pictures WHERE pid = $pid
-
yes but how do I construct the database query the sql statement goes into
i assume there are functions within the include files which query the db meaning i dont need to set up the database connection from scratch
-
/**
* cpg_db_connect()
*
* Connect to the database
**/
function cpg_db_connect()
{
global $CONFIG;
$result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
if (!$result) {
return false;
}
if (!mysql_select_db($CONFIG['dbname'])) {
return false;
}
return $result;
}
The database settings are stored in include/config.inc.php.
-
not quite what i meant but a nudge in the right direction thanks andre
$result= cpg_db_query("SELECT `pid`, `filepath`, `filename`, `title`, `caption`, `keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'");
$PIC_DATA = mysql_fetch_array($result) or die(mysql_error());
but when i load the page after adding the query nothing happens,
no errors, no visable page source just a completly blank page
-
Hard to say what went wrong, if you past only that code snippet.
I don't know how cpg_db_query is set in your code.
I don't know how $CONFIG['TABLE_PICTURES'] is set in your code.
I don't know how $pid is set in your code.
I don't know if a connection to the database already exists.
I don't know why you don't want to establish the database connection with standard PHP functions.
-
I don't know why you don't want to establish the database connection with standard PHP functions.
Sorry i think i am confusing both of us here
I have a link to a page in www.mysite.com/gallery/metapage.php?pid=x
when metapage.php loads i want to get the pid from the url then use the functions defined in the copermine include files as they are in other pages
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$pid= $_GET['pid'];
$result= cpg_db_query("SELECT `pid`, `filepath`, `filename`, `title`, `caption`, `keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'");
$PIC_DATA = mysql_fetch_assoc($result) or die(mysql_error());
$PIC_DATA['url']="{$CONFIG['site_url']}albums{$PIC_DATA['filepath']}{$PIC_DATA['filename']}";
$pgTitle="{$PIC_DATA['title']}";
$pgDesc="blah";
$thumbUrl = str_replace('normal', 'thumb', $PIC_DATA['url']);
$redirectUrl="{$CONFIG['site_url']}displayimage.php?pid={PIC_DATA['pid']}";
?>
as i say I was originally hoping there was a function somewhere in the function list that populated the array $current_pic_data[] which is used in displayimage.php etc but have been unable to find it
-
Nice to know that your custom page is running in the context of Coppermine ::)
$pid= $_GET['pid'];
See: http://documentation.coppermine-gallery.net/en/dev_superglobals.htm
-
Thanks Andre, after the initial confusion its now all working
final code looks something like this
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$pid = $superCage->get->getInt('pid');
$result= cpg_db_query("SELECT `pid`, `filepath`, `filename`, `title`, `caption`, `keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'");
$PIC_INFO = mysql_fetch_assoc($result);
mysql_free_result($result);
$pgTitle="{$PIC_INFO['title']}";
$pgDesc="";
$PIC_INFO['url']="{$CONFIG['site_url']}albums/{$PIC_INFO['filepath']}{$PIC_INFO['filename']}";
$PIC_INFO['thumburl'] = "{$CONFIG['site_url']}albums/{$PIC_INFO['filepath']}thumb_{$PIC_INFO['filename']}";
$PIC_INFO['redirectUrl'] ="{$CONFIG['site_url']}displayimage.php?pid={$PIC_INFO['pid']}";
?>
-
For security reasons I'd change the query to something like
$result = cpg_db_query("SELECT pid, filepath, filename, title, caption, keywords, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE pid='$pid' $FORBIDDEN_SET LIMIT 1");
-
Thanks Joachim
changes made :)