PDA

View Full Version : mysql_pconnect troubleshooting



potsandpeaks
03-13-2009, 11:35 AM
I have a new little script I am trying out that gives me an error upon initial upload.

Here is error:

Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/residua5/public_html/coaching/sys/db.class.php on line 110
Can't go on, DB not initialized.



I realize from searching other posts I do not have access at root level. But I am not familiar enough with this code (I usually do this with a basic config file) to call up a database when their is no user config file to edit for database name, user name, etc.

Where do I insert the code in the script below? I do not see space to define the database name even?

Am I just too far over my head here, or am I missing something simple?

Here is the code around which the error points to....

Thanks in advance for any help.

tim


class db {

var $host;
var $username;
var $pass;
var $dbname;
var $connect_on;
var $debug;
var $q_total;
var $q_select;


function db ( $host = 'localhost', $username = 'root' , $pass = '' , $debug = '0' ) {
$this->host=$host;
$this->username=$username;
$this->pass=$pass;
$this->connect_on=-1;
$this->debug=$debug;
$this->q_total=0;
$this->q_select=0;
}

function connect ($db) {
if ( !mysql_pconnect ($this->host,$this->username,$this->pass) ) return 0;
else $this->connect_on=0;

if ( !@mysql_select_db($db) ) {
if ( $this->debug ) echo "Can't select db $db ...";
} else $this->connect_on=1;

}

felgall
03-13-2009, 01:04 PM
All database and usernames on BlueHost are prefixed with your eight character account name and an underscore.

bhaff007
03-13-2009, 01:19 PM
Change:

function db ( $host = 'localhost', $username = 'root' , $pass = '' , $debug = '0' )

to

function db ( $host = 'localhost', $username = 'your_bh_username' , $pass = 'your_password' , $debug = '0' )

That should make you good to gohttp://wasteoftime.info/forums/dot.jpg

wysiwyg
03-13-2009, 02:24 PM
Those are the default values, and while you could change them directly, it's designed to be called like $db = new db('localhost','username','password') when you create a new "db" object.

The class itself is probably instantiated in another file. You could do a search for files containing "new db" already, if you have a program that supports it.

The default values will be overridden by whatever values are put into the function when it's called, which means replacing them won't work unless the function is called without arguments.

That being said, you could hard-code the values in the db function, and then it wouldn't matter.


$this->host='localhost';
$this->username='bhuser';
$this->pass='password';

I wouldn't recommend it, but it's a possibility.

KazanDaemon
03-13-2009, 04:03 PM
mysql_pconnect will work only as mysql_connect
when php (or fastcgi) process terminates all opened connections associated with process automatically close (including persistent connections)

potsandpeaks
03-14-2009, 09:09 AM
Thanks for all your help...all good points in helping me out with this one.


wysiwyg, you were right on target as well that this would be called up (defined, however you say it) in another file.

I just found that spot this morning and now it is working just fine.

Thank you for all your help.

Tim

phino
05-05-2009, 06:29 PM
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'one5nine_eb'@'box309.bluehost.com' (using password: YES) in /home/one5nine/public_html/edwardbulfango/php1spr09/Application_sp09/config.php on line 6


i'm getting this error. is this the same?

potsandpeaks
05-05-2009, 07:04 PM
basically looks the same as mine.

you can see from my solution that the answer was to find the correct place in another file to input the database name, user name, and password.

It turns out I had outdated information for my script....I had to email support for my script and get the new instructions.

Once I had the correct place to enter the information...it worked like a charm.

Hope that helps.