Jump to content


Photo

cant connect to database....


  • Please log in to reply
10 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 03 October 2006 - 02:54 AM

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?
<?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;
    }
}
?>

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?

#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 03 October 2006 - 03:31 AM

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.

#3 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 03 October 2006 - 03:52 AM

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";


#4 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 03 October 2006 - 03:56 AM

Good call.  Isn't 43998 above the maximum port number anyway?

#5 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 03 October 2006 - 09:02 PM

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?

#6 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 03 October 2006 - 09:05 PM

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

#7 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 03 October 2006 - 09:26 PM

<?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
}
?>

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#8 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 04 October 2006 - 02:13 AM

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!

#9 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 October 2006 - 02:34 AM

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)?
Legend has it that reading the manual never killed anyone.
My site

#10 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 04 October 2006 - 02:42 AM

yeah i have that if i think i know what your talking about.. and im using it

#11 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 04 October 2006 - 07:02 PM

andy do you think you could try it if i gave you the password?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users