Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help, Rewrite wordpress Database user array in wp-config.php

Rewrite wp-config.php database user array to connect every time



4:32 am on Jan 20, 2013 (gmt 0)

Ok, so my HOST has a JQueery limit or max_questions limit or throtles it at 75,000. which im sure all of you out there on a shared host have some sort of limit like me. I only noticed this problem when trying to import 1,000s of products through P. CSV import suite. And of course no one really wants to help you. So.....I found the following code to that does help by randomizing multiple users and droping the number of importing products to 250 at a time. It still hits an overloaded user once in a while but i able no to upload on avg 1000 products an hour. where before, with one user i could only upload a couple hundred an hour. Here is my present code:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'myDATAbaseNAME');

/** MySQL database username */
$auser = array( 'user1', 'user2', 'user3', 'user4', 'user5', 'user6', 'user7', 'user8', 'user9');
$user = $auser[ rand(0,5) ];
define('DB_USER', $user); // Your MySQL username

/** MySQL database password */
define('DB_PASSWORD', 'MYpasswordHERE');

/** MySQL hostname */
define('DB_HOST', 'myhostingaccountname.HOSTmysql.com');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
- - - - - - - - - - - - -- - - - - - - - - - - - - -- - - - - -- -
Now, I found the following php code which as state should:
" This should try every name until it can connect - thus (in theory) exponentially adding available mysql resources your database is alotted."
Here is the code:

function dbConnector(){
$aUser = array("userOne","userTwo","userThree");
$aPass = array("passOne","passTwo","passThree");
for($i=0; $i<sizeof($aUser); $i++){
if(!($oConn = mysql_connect("whatever.powweb.com",$aUser[$i],$aPass[$i]))){
$errorlist .= mysql_error()."
if(!($oConn = mysql_connect("localhost",$aUser[$i],$aPass[$i]))){
$errorlist .= mysql_error()."
return $oConn;
return $oConn;
//sample of a connection call...
//once you've connected and it gives you an object,
//treat it like you would any other MySQL connection object.
$mysql_connection_object = dbConnector();
//do your queries or whatever you want like usual
What I would like is for someone to rewrite the second code above to work in word press. To replace my existing random code in the wp-config.php file. I believe this will solve many peoples problems! Please someone rewrite this code to work! Thanks!


8:46 pm on Jan 20, 2013 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Hi coby187, welcome to WebmasterWorld. Please have a look at the Posting Guidelines for the PHP Server Side Scripting Forum in our forum charter (http://www.webmasterworld.com/php/charter.htm). Have you made any attempt at this yourself yet?


7:12 am on Jan 21, 2013 (gmt 0)

Yes, ive tried, but im not that good at php...im new to all this. previously i had done beginner work on zencart and now im trying something with word press.


4:05 pm on Jan 22, 2013 (gmt 0)

10+ Year Member

Why are you using multiple users? and why are you writing the code in wp-config.php file?

You want some php code to import csv data to wp databse, right? In that case create a new PHP file and write all your code in it. Write some code using just one user then post your code here if you need any help.


5:01 pm on Jan 22, 2013 (gmt 0)

Im keeping it they way it is. the multiple users helps fight fight against the 75,000 jquerry limit per hour. the code that im using randomizes all my users which is located in the wp-config file. this is where you'd rewrite it to the example i found above and replace my existing one.


12:40 am on Jan 23, 2013 (gmt 0)

10+ Year Member

But why do you need jQuery? Isn't it just php and mysql thing?


5:08 am on Jan 23, 2013 (gmt 0)

Look, i barely know anything about anything, i know enough to find things and copy then paste. never taken one class or been taught one thing in this. Alls I know is my Hosting company has 75,000 jquery limit. When i attempt to upload my product database (csv) file of 10,000s of products, it overloads that limit and drops my site for an hour. to counter this i had to shrink my upload file to 250 products and place the random user code in my wp-config file. As you can see above the autmatic connect user php code seems to be a more proficient fix than the random code....though i DO NOT know how to change this into an word press php code that will work and replace my random user code. SO if anyone else knows of a better fix, then give some detailed instructions. Otherwise, I only want help in rewriting that short piece of code above.

Featured Threads

Hot Threads This Week

Hot Threads This Month