Jonny`
02-25-2008, 06:36 PM
Because I'm working with two SQL Connections, one to cP Creator and one to the forum. Links are needed. But when I create a connection then use an old link, it uses the one I just created. Here's the code:
//Add forums to the cP Creator DB to use for posts
if($_POST['module']) {
global $whm;
//Connect to DB
$con = @mysql_connect($_POST['hostname'], $_POST['username'], $_POST['password']);
if(!$con) {
echo '<span class="errors">Connection was not made to the mySQL Server!</span>';
}
else {
$db = @mysql_select_db($_POST['database'], $con);
if(!$db) {
echo '<span class="errors">Could not select database!</span>';
}
else {
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_hostname', '{$whm->strip($_POST['hostname'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_username', '{$whm->strip($_POST['username'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_password', '{$whm->strip($_POST['password'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_forum', '{$whm->strip($_POST['forum'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_database', '{$whm->strip($_POST['database'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
echo '<span class="errors">Your forum has been added!</span>';
}
}
}
It uses the $con and says that the table doesn't exist.
//Add forums to the cP Creator DB to use for posts
if($_POST['module']) {
global $whm;
//Connect to DB
$con = @mysql_connect($_POST['hostname'], $_POST['username'], $_POST['password']);
if(!$con) {
echo '<span class="errors">Connection was not made to the mySQL Server!</span>';
}
else {
$db = @mysql_select_db($_POST['database'], $con);
if(!$db) {
echo '<span class="errors">Could not select database!</span>';
}
else {
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_hostname', '{$whm->strip($_POST['hostname'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_username', '{$whm->strip($_POST['username'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_password', '{$whm->strip($_POST['password'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_forum', '{$whm->strip($_POST['forum'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
mysql_query("INSERT INTO ".$whm->sql['pre']."modulesettings (name,value,module,package) VALUES('p2hforum_database', '{$whm->strip($_POST['database'])}', 'Post 2 Host', '{$whm->strip($_POST['name'])}')", $whm->sql['con']) or die(mysql_error());
echo '<span class="errors">Your forum has been added!</span>';
}
}
}
It uses the $con and says that the table doesn't exist.
