Plugin install code help. Plugin install code help.
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Plugin install code help.

Started by just_some_guy, October 28, 2007, 02:32:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

just_some_guy

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,
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad

you forget table name under query
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

Sorry, that was an error when i posted its actually `{$CONFIG['TABLE_CONFIG']}`  and it doesent work. just returns the error.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

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.


Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Nibbler

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).

just_some_guy

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
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

I fixed it, but when you create the admin button what should it link to? i know its plugin_name/????

Thanks,
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

It depends on what you up to with admin button , usually it links to configuration (e.g. config.php)
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

Quote from: Sami on October 28, 2007, 02:44:15 PM
GauGau already told you , please post to plugin board instead of Coppermine coding discussion borad
Moving accordingly.


just_some_guy

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,
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

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
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

#11
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.
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Sami

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
‍I don't answer to PM with support question
Please post your issue to related board

just_some_guy

Fantastic Sami, thats much better thanks again!
Tambien, Hablo Español      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums