forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: just_some_guy on October 28, 2007, 02:32:37 pm
-
Hello,
I am making a plugin and seems to be good apart from the install function.
It works without the install function but just reports a critical error when i put the code in. Heres the code:
<?php
function this_install() {
global $CONFIG;
$sql = ("INSERT INTO `{$CONFIG['TABLE_PREFIX']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");
$result = mysql_query($sql);
}
?>
any ideas?
thanks,
-
GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad
you forget table name under query
-
Sorry, that was an error when i posted its actually `{$CONFIG['TABLE_CONFIG']}` and it doesent work. just returns the error.
-
I have made an improvment.
I know have this:
function this_install() {
// Install
if ($_POST['submit']=='Submit') {
return true;
// Loop again
} else {
return 1;
}
$sql = ("INSERT INTO `{$CONFIG['TABLE_CONFIG']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");
}
When i click install it shows the configure part of the codebase and when i click submit it just loops the same page. What is wrong with the above code?
Thanks,
ps the if else clause in that code is from the FileMove plugin.
-
1. Code placed after a return; will never run.
2. $sql is just a string, so does nothing anyway. You need to actually run the query using cpg_db_query($sql).
-
I now have this:
What should go after the $_POST? is it correct?
function this_install() {
// Install
if ($_POST['submit']=='Submit') {
$sql = ("INSERT INTO `{$CONFIG['TABLE_CONFIG']}` (`name` ,`value` )VALUES ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text'), ('text', 'text'),('text', 'text'),('text', 'text'),('text', 'text')");
cpg_db_query($sql);
return true;
// Loop again
} else {
return 1;
}
}
And it just does the same, any ideas?
Thanks Nibbler
-
I fixed it, but when you create the admin button what should it link to? i know its plugin_name/????
Thanks,
-
It depends on what you up to with admin button , usually it links to configuration (e.g. config.php)
-
GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad
Moving accordingly.
-
Using Frantz's backup plugin as an example the link is "file=backup/backup" where does this link to? is it backup.php where backup is the file which contains the config? am i getting the function of "function plugin_configure()" confused? Right now i am thinking that this contains the information that can be configured (ie the content that the button links to). This may be wrong and i need to then create a file called config.php to contain the config information.
What is correct?
Thanks,
-
file=folder/file means :
include file.php from {gallery root}/plugins/folder into index.php
and yes backup.php contains configuration settings for that plugin
You can name the file, what ever you want to
-
Aha! thanks,the problem is that the .php extension is not required. it can just be file="plugin/config". Thanks Sami.
On the config page how do i make it fit in with the theme?
What file must i include to solve this error on the config page?
Undefined variable: CONFIG
Call to undefined function cpg_db_query()
Thanks,
And very sorry for all the questions, im not new to php and mysql but i am new to pluginizing.
-
just add this to the very first of your file to define CONFIG and coppermine functions
require('include/init.inc.php');
then use pageheader function to add coppermine header to your page
pageheader($title);
$title is your page title
-
Fantastic Sami, thats much better thanks again!