By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,192 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,192 IT Pros & Developers. It's quick & easy.

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

P: 1
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.
May 18 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Changed thread title to better reflect contents.

Heya, iceboy. Welcome to TSDN!

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.
May 18 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.