Jump to content

Archived

This topic is now archived and is closed to further replies.

jwk811

cant connect to database....

Recommended Posts

Warning: mysql_connect(): Can't connect to MySQL server on 'mysqladmin2.secureserver.net' (111) in /home/content/j/w/k/jwk811/html/db.php on line 10
Unable to connect to database! Please try again later.

And heres my db.php file. Can you tell me what I'm doing wrong?
[code]<?php
//Connect To Database
$hostname="mysqladmin2.secureserver.net:43998";
$username="091381";
$password="(mypassword";
$dbname="091381";
$usertable="users";
$yourfield = "uderid";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);

$query = "SELECT * FROM $usertable";
$result = mysql_query($query);
if($result) {
    while($row = mysql_fetch_array($result)){
        $name = $row["$yourfield"];
        echo "Name: ".$name;
    }
}
?> [/code]

I can see that the die part is coming up in the script. What would make it do that? I think there might be something wrong with the hostname.. I'm using phpMYadmin does that look like the right thing for host?

Share this post


Link to post
Share on other sites
Assuming the other things are correct, it probably is something to do with the host name.  I would verify that that is the right host.  The syntax looks fine though.

Share this post


Link to post
Share on other sites
Verify the following:

$hostname="mysqladmin2.secureserver.net:43998";
$username="091381";
$password="(mypassword";

Your problem lies in either hostname, username, or password. The port number in the hostname seems very odd, usually MySQL is never run on such a high port, try it without the port numbers, so:

$hostname="mysqladmin2.secureserver.net";

Share this post


Link to post
Share on other sites
yeah i think i already tried that.. ill try again and see what happens tho, thanks. and i had another questions.. you know with the membership thing in a database.. this code to connect is asking for one field in the table.. dont i want the whole table?

Share this post


Link to post
Share on other sites
Warning: mysql_connect(): Can't connect to MySQL server on 'mysqladmin2.secureserver.net' (111) in /home/content/j/w/k/jwk811/html/db.php on line 10
Unable to connect to database! Please try again later.


eerrrrggggg

Share this post


Link to post
Share on other sites
[code]<?php
//Connect To Database
$hostname="mysqladmin2.secureserver.net:43998";
$username="091381";
$password="(mypassword";
$dbname="091381";
$usertable="users";
$yourfield = "uderid";

mysql_connect($hostname,$username, $password);
mysql_select_db($dbname);
echo mysql_error();
$query = "SELECT * FROM $usertable";
$result = mysql_query($query);
if($result) {
// stuff here
}
?> [/code]
try that, just with stuff here put your other stuff.

Also double check your password, double check your username, replace that connection address with "localhost" and see if that works.
If none of that works, then what is the url of your web hosting company.

Share this post


Link to post
Share on other sites
okay i tried that new code and got a bunch of warning saying cant connect to database and cant find a link to connect to server. i think it might have something to do with the password because when i used a fake password to see what would happen the same warnings came up about the connecting but im sure i didnt type in what i thought it was to be wrong. im using the same pasword that i use to log into my database or my account on phpmyadmin right? And ive tried a lot to find out why i cant connect and i still dont know what to do. is there anyone out there that could try it out for me? and see what the problem is and if its just me or whatever. ive had this same problem a while ago about not connecting and gave up for a while because i just couldnt find out what the problem was. thanks for the help!

Share this post


Link to post
Share on other sites
Can't you actually find out the connection string from your web host (or the piece of paper on which you wrote the information when you created the database)?

Share this post


Link to post
Share on other sites
yeah i have that if i think i know what your talking about.. and im using it

Share this post


Link to post
Share on other sites

×

Important Information

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.