PDA

View Full Version : Plugin not adding to Databse


Dragonsys
11-19-2015, 06:11 PM
For some reason I cannot get this code to work, am I just missing something simple?

$db->query_write("
INSERT INTO " . TABLE_PREFIX . "bbcode
(bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage, options)
VALUES
('fa', '<i class="fa %1$s"></i>', 'fa-male', 'Use Font Awesome icons. For a list of available icons see here: https://fortawesome.github.io/Font-Awesome/icons/', 0, 'Font Awesome', '', 31)
");
build_bbcode_cache();

If I run the INSERT manually, it works fine. The uninstall works, just the install I am having issues with

MarkFL
11-19-2015, 06:18 PM
Try adding this line before the query:

require_once(DIR . '/includes/adminfunctions.php');

Dragonsys
11-19-2015, 06:33 PM
Didn't make a difference. Here is the full xml file, just in case

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="dso_fa" active="1">
<title>DSO - Font Awesome</title>
<description>Adds Font Awesome v4.4.0 support to vBulletin</description>
<version>1.0.0</version>
<url />
<versioncheckurl />
<dependencies>
<dependency dependencytype="vbulletin" minversion="4.1.8" maxversion="" />
</dependencies>
<codes>
<code version="1.0.0">
<installcode><![CDATA[$db->query_write("
INSERT INTO ".TABLE_PREFIX."bbcode
(bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage, options)
VALUES
('fa', '<i class="fa %1$s"></i>', 'fa-male', 'Use Font Awesome icons. For a list of available icons see here: https://fortawesome.github.io/Font-Awesome/icons/', 0, 'Font Awesome', '', 31)
");
build_bbcode_cache();]]>
</installcode>
<uninstallcode><![CDATA[$db->query_write("
DELETE FROM ".TABLE_PREFIX."bbcode WHERE bbcodetag = 'fa' LIMIT 1;
");
build_bbcode_cache();]]>
</uninstallcode>
</code>
</codes>
<templates>
</templates>
<stylevardfns>
</stylevardfns>
<stylevars>
</stylevars>
<plugins>
<plugin active="1" executionorder="5">
<title>Font Awesome CSS</title>
<hookname>parse_templates</hookname>
<phpcode><![CDATA[$dso_fa_css = " <link rel=\"stylesheet\" type=\"text/css\" href=\"./DSO/font-awesome-4.4.0/css/font-awesome.css\" />";

$template_hook['headinclude_css'] .= $dso_fa_css;]]></phpcode>
</plugin>
</plugins>
<phrases>
</phrases>
<options>
</options>
<helptopics>
</helptopics>
<cronentries>
</cronentries>
<faqentries>
</faqentries>
<navigation>
</navigation>
</product>


It is strange, as I have not had a problem with this in any other plugin I have written, so I'm sure it has to be something I am just missing from staring at the screen...

MarkFL
11-19-2015, 06:53 PM
Okay, try this as your query:

$db->query_write("
INSERT INTO " . TABLE_PREFIX . "bbcode
(bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage, options)
VALUES
('fa', '<i class="fa %1\$s"></i>', 'fa-male', 'Use Font Awesome icons. For a list of available icons see here: https://fortawesome.github.io/Font-Awesome/icons/', 0, 'Font Awesome', '', 31)
");
build_bbcode_cache();

Note: I added a backslash before the dollar sign in the string representing the parameter of the BCode.

Dragonsys
11-19-2015, 07:02 PM
nope, but it did get me in the right area. I replaced all the varchar with 1 2 3 etc, and now it inserts. So I just have to try one at a time to find the faulty one.

Thank you

MarkFL
11-19-2015, 07:06 PM
nope, but it did get me in the right area. I replaced all the varchar with 1 2 3 etc, and now it inserts. So I just have to try one at a time to find the faulty one.

Thank you

Actually, the query should be:

$db->query_write("
INSERT INTO " . TABLE_PREFIX . "bbcode
(bbcodetag, bbcodereplacement, bbcodeexample, bbcodeexplanation, twoparams, title, buttonimage, options)
VALUES
('fa', '<i class=\"fa %1\$s\"></i>', 'fa-male', 'Use Font Awesome icons. For a list of available icons see here: https://fortawesome.github.io/Font-Awesome/icons/', 0, 'Font Awesome', '', 31)
");
build_bbcode_cache();

The double-quotes also need to be escaped. :)

Dragonsys
11-19-2015, 07:13 PM
that was it. I knew it was something simple I was forgetting. Thanks Mark