forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: just_some_guy on November 01, 2007, 11:03:10 pm

Title: Use of $CONFIG in a query
Post by: just_some_guy on November 01, 2007, 11:03:10 pm
Hello,

Not quite sure what is wrong here, the query works fine using `cpg1411_config` but when i use {$CONFIG['TABLE_CONFIG']} in replace of the other name i get an unexpected T_STRING. Its for my plugin and i have also globlized CONFIG too before this.

this works -

Code: [Select]
$sql = 'INSERT INTO `cpg1411_config` (`name`, `value`) VALUES (\'text\', \'text'\' ), (\'text\', \'text'\' ),(\'text\', \'text'\ ), (\'text\', \'text'\), (\'text\', \'text\' );';
cpg_db_query($sql);

this does not -

Code: [Select]
$sql = 'INSERT INTO {$CONFIG['TABLE_CONFIG']}  (`name`, `value`) VALUES (\'text\', \'text\' ), (\'text\', \'text\'),(\'text\', \'text\' ), (\'text\', \'text\'), (\'text\', \'text\' );';
cpg_db_query($sql);

any ideas?

thanks,
Title: Re: Use of $CONFIG in a query
Post by: Nibbler on November 02, 2007, 12:39:30 am
{$CONFIG['TABLE_CONFIG']} only works within double quotes. Please don't ask general PHP coding questions here.
Title: Re: Use of $CONFIG in a query
Post by: Joachim Müller on November 02, 2007, 07:23:59 am
You should also review your use of backticks and single quotes.
Title: Re: Use of $CONFIG in a query
Post by: just_some_guy on November 02, 2007, 07:51:27 pm
Ok thanks guys, i managed to solve the problem by comparing the code amongst the code used in sami's copperad plugin. Turns out the problem was the (`name`, `value`) . and i used " .$CONFIG['TABLE_PREFIX']. " instead
Thanks!