Jump to content

I need help with some scripting for the site


carbonfibah

Recommended Posts

I need a hand with some scripting.

I am going to explain why you have all been seeing so many errors on CoDz. One issue is that there could be some scripts that are not closing properly or fast enough and connections to the database are being filled up quickly. The host only allow I think 15 connections or so per user per database.( that doesn't mean only 15 users on the forum at a time) Right now I have the forum and the chat on one database with only one user assigned to it. Now If I add more users to the database that means more connections available. So say I add 4 more users, I now have 60 connections available to that database. Now the errors are not all the time even under heavy traffic, so adding these extra users (extra connections) should fix the max users connections to database you have seen.

Now I think I have found the way to fix this issue however I am having some trouble with some script. This is for the config.php for the forum.

I was told to replace


    $dbuser = 'callofd3_carbon';
with
    $db_user = 'callofd3_carbon';

    $db_user_array[] = 'callofd3_carbon';

    $db_user_array[] = 'callofd3_carbon2';

    $db_user_array[] = "'callofd3_carbon3';

    $db_user_array[] = "'callofd3_carbon4';

    $db_user = $db_user_array[ rand( 0, ( sizeof($db_user_array) -1 ) ) ];

Which makes sense , but I am stuck. I think I have to change something on the last line of code but I don't have any idea what it is. I may even be missing some parts not just on the last line. So if anyone has any ideas of how to correctly complete this part of code, the errors on codz should stop forever and you will never have to see those damn errors and you and everyone will be so happy.

Link to comment
  • Replies 18
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I need a hand with some scripting.

I am going to explain why you have all been seeing so many errors on CoDz. One issue is that there could be some scripts that are not closing properly or fast enough and connections to the database are being filled up quickly. The host only allow I think 15 connections or so per user per database.( that doesn't mean only 15 users on the forum at a time) Right now I have the forum and the chat on one database with only one user assigned to it. Now If I add more users to the database that means more connections available. So say I add 4 more users, I now have 60 connections available to that database. Now the errors are not all the time even under heavy traffic, so adding these extra users (extra connections) should fix the max users connections to database you have seen.

Now I think I have found the way to fix this issue however I am having some trouble with some script. This is for the config.php for the forum.

I was told to replace


$dbuser = 'callofd3_carbon';
with
    $db_user = 'callofd3_carbon';
$db_user_array[] = 'callofd3_carbon';
$db_user_array[] = 'callofd3_carbon2';
$db_user_array[] = "'callofd3_carbon3';
$db_user_array[] = "'callofd3_carbon4';
$db_user = $db_user_array[ rand( 0, ( sizeof($db_user_array) -1 ) ) ];

Which makes sense , but I am stuck. I think I have to change something on the last line of code but I don't have any idea what it is. I may even be missing some parts not just on the last line. So if anyone has any ideas of how to correctly complete this part of code, the errors on codz should stop forever and you will never have to see those damn errors and you and everyone will be so happy.

Dude all I can say is wow. I have always wanted to be able to code fluently but I didn't know where to start. sorry this is no help but where do you think I could start out?

Link to comment

idk this language exactly, I've only looked at java, so I'm guessing using the similarities for my answer...so I might be completely wrong, but are those "s before the 'callofd3_carbon3' and 'callofd3_carbon4' supposed to be there? and in the array, do you have to put int's in the brackets? Like this:

$db_user = 'callofd3_carbon';
$db_user_array[0] = 'callofd3_carbon';
$db_user_array[1] = 'callofd3_carbon2';
$db_user_array[2] = 'callofd3_carbon3';
$db_user_array[3] = 'callofd3_carbon4';
$db_user = $db_user_array[ rand( 0, ( sizeof($db_user_array) -1 ) ) ];

again. maybe I'm totally wrong, cause I've only looked at java.

EDIT: I kinda looked it up...and no I guess you don't need the int's :( like I said lol just guessing...I don't really understand why you don't need it...I would need to research this language to get it :P

EDIT 2: I GET IT NOW lol, I can still be of no help unless my "s idea is right...but now I understand why you don't need int's, I guess I just need to see like a whole script before I understand what is going on here...like I have no idea what 'callofd3_carbon' and 2, 3, and 4 are even doing. but I get that it's setting the $db_user to a random indexed thing in the array....I think lol if only this was written in java :P

Link to comment

I believe carbon is attempting to load balance the sites current database to a collection of usernames. Was this something that phpbb supports or are you just trying it. I assume you have gone in to your hosting panel and set up a series of usernames associated with the database. If the passwords of the usernames are all different then you will need the same script but for $db_pass aswell.


$db_user_array[] = 'callofd3_carbon';
$db_user_array[] = 'callofd3_carbon2';
$db_user_array[] = "'callofd3_carbon3';
$db_user_array[] = "'callofd3_carbon4';
$db_user = array_rand($db_user_array, 1);

Link to comment

From what I've been able to gather from the phpBB forums is that only the web host can change the max number of user connections. I'll keep on looking though to see what I can find.

EDIT: A dude on the support team for phpBB confirmed that only the web host can change the "Max_user_connections" thing, not sure if this helps.

Link to comment

Yes I know only the host can change the max user connections...

but my host also told me a way to bypass that, which is wierd that they will tell me how to get around it but not just increase the amount of connections... anyway....

Let me show you the full code, (obviously some parts are changed for privacy reasons)

This config file is how the forum configures (connects) to the database where all the information is stored. So this config file is connecting to only one user on the database and I want to add more users, which can be done, but I am not familiar with this process and I have had trouble finding the proper solution online myself.

Here is the full script.

<?php

// phpBB 3.0.x auto-generated configuration file

// Do not change anything in this file!

$dbms = 'mysql';

$dbhost = 'localhost';

$dbport = '';

$dbname = 'databasename';

$dbuser = 'databaseusername';

$dbpasswd = 'DBuser'spassword';

$table_prefix = 'phpbb3_';

$acm_type = 'file';

$load_extensions = '';


@define('PHPBB_INSTALLED', true);

// @define('DEBUG', true);

// @define('DEBUG_EXTRA', true);

?>

Now I was told to replace the $dbuser = 'databaseusername'; with the code i presented in my first post. I just don't know how to complete the script to run correctly.

Link to comment

Bump!

Yeah this is very important. Unfortunetly I don't know anything about running scripts but im sure some of the admins would help you out Carbon. Try looking up the problem on google or youtube and see what ways it can be fixed. I don't really know what I am talking about but I am just throwing out suggestions. Sorry Carbon :(

Link to comment


// phpBB 3.0.x auto-generated configuration file

//Usernames
$db_user_array[] = 'callofd3_carbon';
$db_user_array[] = 'callofd3_carbon2';
$db_user_array[] = "'callofd3_carbon3';
$db_user_array[] = "'callofd3_carbon4';


//passwords
$db_pass_array[] = 'callofd3_carbon_password';
$db_pass_array[] = 'callofd3_carbon2_password';
$db_pass_array[] = "'callofd3_carbon3_password';
$db_pass_array[] = "'callofd3_carbon4_password';

// Do not change anything in this file!
$dbms = 'mysql';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'databasename';

//Changed for multi-users
$num = rand (0 , count($db_user_array));

$dbuser = $db_user_array[$num];
$dbpasswd = $db_pass_array[$num] ;


$table_prefix = 'phpbb3_';
$acm_type = 'file';
$load_extensions = '';

@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);
?>

Just enter the usernames and the passwords. Each Username must match its own password.

EDIT: corrected syntax.

Link to comment

Ok I entered everything I need however this error came up.

Parse error: syntax error, unexpected T_VARIABLE in /home4/callofd3/public_html/forum/config.php on line 24

that line is

$num = rand (0 , count($db_user_array));
so maybe something needs to be added or changed in this section
//Changed for multi-users

$num = rand (0 , count($db_user_array));


$dbuser = $db_user_array[$num];

$dbpasswd = $db_pass_array[$num] ;



$table_prefix = 'phpbb3_';

$acm_type = 'file';

$load_extensions = '';


@define('PHPBB_INSTALLED', true);

// @define('DEBUG', true);

// @define('DEBUG_EXTRA', true);

?>

Link to comment

Ok I entered everything I need however this error came up.

Parse error: syntax error, unexpected T_VARIABLE in /home4/callofd3/public_html/forum/config.php on line 24

that line is

Sorry my fault i looked over it again it was due to some double quotes. Try this. Best of Luck.

// phpBB 3.0.x auto-generated configuration file

//Usernames
$db_user_array[] = 'callofd3_carbon';
$db_user_array[] = 'callofd3_carbon2';
$db_user_array[] = 'callofd3_carbon3';
$db_user_array[] = 'callofd3_carbon4';


//passwords
$db_pass_array[] = 'callofd3_carbon_password';
$db_pass_array[] = 'callofd3_carbon2_password';
$db_pass_array[] = 'callofd3_carbon3_password';
$db_pass_array[] = 'callofd3_carbon4_password';

// Do not change anything in this file!
$dbms = 'mysql';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'databasename';

//Changed for multi-users
$num = rand (0 , count($db_user_array));

$dbuser = $db_user_array[$num];
$dbpasswd = $db_pass_array[$num] ;


$table_prefix = 'phpbb3_';
$acm_type = 'file';
$load_extensions = '';

@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);
?>

Link to comment

Thats due to the set-up of your mysql, not the script. Check to make sure the passwords of the mysql users match up with the usernames.

Access denied for user 'callofd3'@'localhost' (using password: NO) [1045]

This is due to the a username or password being incorrect, In you control pannel make sure the usernames are linked up to the CODz Database. Since i don't have any access to the database admin then there is nothing more that i can suggest.

Link to comment

Thats due to the set-up of your mysql, not the script. Check to make sure the passwords of the mysql users match up with the usernames.

Access denied for user 'callofd3'@'localhost' (using password: NO) [1045]

This is due to the a username or password being incorrect, In you control pannel make sure the usernames are linked up to the CODz Database. Since i don't have any access to the database admin then there is nothing more that i can suggest.

Well all the passwords for the users connecting to the forum's database are correct. Hmm, we are so close. Once I replace the old config with the new one we are working on, the site is still up until you log out or log in and then sometimes randomly you get the error. ugh

Link to comment

Could "Access denied for user 'callofd3'@'localhost' (using password: NO) [1045]" simply mean that you either don't need a password for the localhost bit, or there is a line of code or something where you need to enable the passwords?

Sorry if I'm not being much help =/

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Privacy Policy, Code of Conduct, We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. .