Connecting Tech Pros Worldwide Help | Site Map

Unable to connect to MySQL database... what's 'hostname'?

Newbie
 
Join Date: May 2007
Posts: 1
#1: May 18 '07
Hello to all,I have a problem to connect PHP & MySQL together.
I have created a form that gets the username & password from admin and connect him to database.the part of PHP script that connect to mysql is as follow:
Expand|Select|Wrap|Line Numbers
  1. $db=mysql_pconnect("hostname",$username,$password); 
  2. if(!$db){ 
  3. echo"ERROR:connecting failed";
  4. exit;  } 
  5. else  
  6. echo"you have connected to database succsessfully"; 
I want to know what should i write instead of "hostname" parameter in mysql_pconnect function?
I use IIS as localhost server and DreamWeaver as editor. the path of mysql is :C:/Program Files/MySQL/MySQL Server 6.0/ ,(mysql is not install in root folder of localhost) and TCP Port is 3306.
Can i creat a connection with DreamWeaver directly?

Tanx very much.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: May 18 '07

re: Unable to connect to MySQL database... what's 'hostname'?


Changed thread title to better reflect contents.

Heya, iceboy. Welcome to TSDN!

Quote:

Originally Posted by iceboy

Expand|Select|Wrap|Line Numbers
  1. $db=mysql_pconnect("hostname",$username,$password); 
  2. if(!$db){ 
  3. echo"ERROR:connecting failed";
  4. exit;  }

Do you need to make a persistent connection to your MySQL database? 99% of the time, the answer is 'no'. Try using mysql_connect instead, and then if you really need a persistent connection (believe me, you'll know if you do!), then change it.

"hostname" is the hostname of the server that runs your MySQL server app. 99% of the time, this will be 'localhost', but you can also use an IP address (w/ or w/o port number) or a domain name if your MySQL server is on a different machine than your web server.
Reply