Thanks, got the test page working.
Well, it worked as a stand-alone page, but when i tried integrating it into another page, I get an error:
Code:
Fatal error: Call to a member function unlock_tables() on a non-object in /home/.sites/22/site13/web/livexchange/forums/includes/functions.php on line 4366
here's what I have:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Glossary Administration</title>
</head>
<body>
<h2 align="left">Glossary Administration</h2>
<p align="left">
<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.
define('THIS_SCRIPT', 'admin');
// ########################## REQUIRE BACK-END ############################
chdir('/pathtosite/forums');
require_once('./global.php');
// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
if (!is_member_of($vbulletin->userinfo, 6) AND !is_member_of($vbulletin->userinfo, 7))
{
print_no_permission();
}
echo 'You are logged in!<br>';
// Your upload code here
$configfile = "config.php";
require $configfile;
$db = mysql_connect("$host", "$username", "$password");
mysql_select_db("$databasename", $db);
//Add word
if($action=="add")
{
if($word&&$definition)
{
$addWord=mysql_query("INSERT INTO `mdglossary` (`word`, `definition`) VALUES ('$word', '$definition')", $db);
if($addWord)
{
echo "The word $word and it's definition has been successfully added to the database";
}
if(!$addWord)
{
echo "There has been an error in adding the word $word";
}
}
if(!$word||!$definition)
{
echo "
<form name=\"mdglossary\" action=\"$PHP_SELF\" method=\"post\">
<b>Word</b>
<br>
<i>The word you want adding</i>
<br>
<input name=\"word\" type=\"text\" value=\"\" maxlength=\"40\">
<br>
<br>
<b>Definition</b>
<br>
<i>The definition of the word</i>
<br>
<textarea name=\"definition\" rows=\"6\" cols=\"50\" ></textarea>
<br>
<input name=\"action\" type=\"hidden\" value=\"add\">
<input type=\"submit\" value=\"Add\"> <input type=\"reset\" value=\"Reset\">
</form>
";
}
}
//Edit word
if($action=="edit")
{
if($word&&$definition)
{
$updateIt=mysql_query("UPDATE mdglossary SET word='$word', definition='$definition' WHERE id='$id'",$db);
if($updateIt)
{
echo "The word $word has been successfully updated";
}
if(!$updateIt)
{
echo "There has been an error in updating the word $word";
}
}
if(!$word&&!$defintion)
{
$getInfo=mysql_query("SELECT * FROM `mdglossary` WHERE id=$id",$db);
if($theInfo=mysql_fetch_array($getInfo))
{
echo "
<form name=\"mdglossary\" action=\"$PHP_SELF\" method=\"post\">
<b>Word</b>
<br>
<i>The word you want editing</i>
<br>
<input name=\"word\" type=\"text\" value=\"";
printf($theInfo["word"]);
echo "\" maxlength=\"40\">
<br>
<br>
<b>Definition</b>
<br>
<i>The definition of the word</i>
<br>
<textarea name=\"definition\" rows=\"6\" cols=\"50\" >";
printf($theInfo["definition"]);
echo "</textarea>
<br>
<input name=\"action\" type=\"hidden\" value=\"edit\">
<input name=\"id\" type=\"hidden\" value=\"$id\">
<input type=\"submit\" value=\"Update\"> <input type=\"reset\" value=\"Reset\">
</form>
";
}
else
{
echo "There has been an error";
}
}
}
//Delete word
if($action=="delete")
{
if($check=="yes")
{
$deleteIt=mysql_query("DELETE FROM mdglossary WHERE id=$id",$db);
if($deleteIt)
{
echo "The word has successfully been deleted";
}
if(!$deleteIt)
{
echo "There has been an error whilst the word was being deleted. Please try again";
}
}
else
{
$getDeleteInfo=mysql_query("SELECT * FROM mdglossary WHERE id='$id'",$db);
$deleteInfo=mysql_fetch_array($getDeleteInfo);
echo "Are you sure you want to delete the following word?<br>";
echo "
<dl>
<dt><b>
";
printf($deleteInfo["word"]);
echo "
</b></dt>
<dd>
";
printf($deleteInfo["definition"]);
echo "
</dd>
</dl>
";
echo "<br><a href=\"$PHP_SELF?action=delete&id=$id&check=yes\">Yes</a> <a href=\"$PHP_SELF?action=main\">No</a>";
}
}
//Get Code
if($action=="getcode")
{
$getInfo=mysql_query("SELECT * FROM `mdglossary` WHERE id=$id",$db);
if($getCode=mysql_fetch_array($getInfo))
{
$lowWord=strtolower($getCode["word"]);
echo "The code that you can copy and paste the word - <b>";
printf($getCode["word"]);
echo "</b> - into your pages is:<br><br>";
echo "<form><textarea cols=\"50\" rows=\"5\">";
echo "<a href=\"$roottoglossary?word=$lowWord\" class=\"glossary\" title=\"Click here to find out what this word means\">";
printf($getCode["word"]);
echo "</a>";
echo "</textarea></form>";
echo "Example:<br><br><a href=\"$roottoglossary?word=$lowWord\" class=\"glossary\" title=\"Click here to find out what this word means\">";
printf($getCode["word"]);
echo "</a>";
}
else
{
echo "Sorry, there has been an error";
}
}
//Add wordpack
if($action=="addwordpack")
{
if($packname)
{
echo "Include file:<br>";
if(include ($packname))
{
$insertPack=mysql_query($insertLines);
if($insertPack)
{
echo "the pack has been added successfully<br>";
}
else
{
echo "Sorry there has been an error<br>";
}
}
else
{
echo "Sorry, there has been a problem opening $packname. Check that you have uploaded it correctly and that you have typed in the name correctly.";
echo "
<br>
<form name=\"pack\" action=\"$PHP_SELF\" method=\"get\">
<input name=\"packname\" type=\"text\" value=\"\">
<input name=\"action\" type=\"hidden\" value=\"addwordpack\">
<br>
<input type=\"submit\" value=\"Add\">
</form>
";
}
$rep = "<br>(";
$insertLines = ereg_replace("\(", $rep, $insertLines);
echo $insertLines;
}
else
{
echo "Type in the filename of the wordpack you want to add. (ie <i>internetpack.php</i>)";
echo "
<br>
<form name=\"pack\" action=\"$PHP_SELF\" method=\"get\">
<input name=\"packname\" type=\"text\" value=\"\">
<input name=\"action\" type=\"hidden\" value=\"addwordpack\">
<br>
<input type=\"submit\" value=\"Add\">
</form>
";
}
}
//Help
if($action=="help")
{
echo "For up-to-date help, information and upgrades to MD Glossary, as well as other new programs to use on your website, visit <a href=\"http://www.matthewdingley.co.uk/programs/glossary/\" target=\"_blank\">MD Web</a>";
}
//Main menu
if($action=="main"||!$action)
{
echo "<a href=\"$PHP_SELF?action=add\">Add a word</a> <a href=\"$PHP_SELF?action=help\">Help</a><br><br>";
echo "You can also go to <a href=\"www.matthewdingley.co.uk/programs/news/\">MD Web</a> and download a wordpack. This will have loads of pre-done words for you to use. When you have downloaded the
word pack, click <a href=\"$PHP_SELF?action=addwordpack\">here</a> to install it.";
$getWords=mysql_query("SELECT * FROM mdglossary ORDER BY word");
if($getWordArray=mysql_fetch_array($getWords))
{
echo "<table width=\"90%\" cellspacing=\"8\" cellpadding=\"0\">";
do
{
echo "
<tr>
<td>
<dl>
<dt><b>
";
printf($getWordArray["word"]);
echo "
</b></dt>
<dd>
";
printf($getWordArray["definition"]);
echo "
</dd>
</dl>
</td>
<td>
<a href=\"$PHP_SELF?action=edit&id=";
printf($getWordArray["id"]);
echo "
\">Edit</a>
</td>
<td>
<a href=\"$PHP_SELF?action=delete&id=";
printf($getWordArray["id"]);
echo "
\">Delete</a>
</td>
<td>
<a href=\"$PHP_SELF?action=getcode&id=";
printf($getWordArray["id"]);
echo "
\">Get code</a>
</td>
</tr>
";
}
while($getWordArray=mysql_fetch_array($getWords));
echo "</table>";
}
else
{
echo "<br><br>There are currently no words in the database. <a href=\"$PHP_SELF?action=add\">Add a word</a>";
}
}
if($action=="add"||$action=="edit"||$action=="delete"||$action=="getcode"||$action=="install"||$action=="addwordpack"||$action=="help")
{
echo "<br><br><a href=\"$PHP_SELF?action=main\">Main menu</a> <a href=\"$PHP_SELF?action=add\">Add a word</a> <a href=\"$PHP_SELF?action=help\">Help</a>";
}
?>
</body>
</html>