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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iceboy
    New Member
    • May 2007
    • 1

    #1

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

    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:
    [CODE=php]$db=mysql_pconn ect("hostname", $username,$pass word);
    if(!$db){
    echo"ERROR:conn ecting failed";
    exit; }
    else
    echo"you have connected to database succsessfully"; [/CODE]

    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.
    Last edited by pbmods; May 18 '07, 04:37 PM. Reason: Changed code language. Thanks for using CODE tags!
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Changed thread title to better reflect contents.

    Heya, iceboy. Welcome to TSDN!

    Originally posted by iceboy
    [CODE=php]$db=mysql_pconn ect("hostname", $username,$pass word);
    if(!$db){
    echo"ERROR:conn ecting failed";
    exit; }[/code]
    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.

    Comment

    Working...