1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help connecting PHP and mySQL

Discussion in 'PHP' started by The Alchemist, Jul 8, 2012.

  1. The Alchemist

    The Alchemist New Member

    Joined:
    Jul 7, 2012
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Hello everyone..
    I'm trying to connect to my mySQL database named mydb using PHP.
    The hosting site where I've created my database says : Server: "Localhost via UNIX socket"
    So, if I connect with mysql_connect($hostname,$user,$password);
    What will be the value of $hostname? will it be $hostname='localhost:9000' or 'localhost' or what should I put?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    The host should be your host's IP address or hostname. It can be localhost if your PHP and MySQL are on the same server of your host.
     
    The Alchemist likes this.
  3. The Alchemist

    The Alchemist New Member

    Joined:
    Jul 7, 2012
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    I think its localhost... Thanks for helping.
     
  4. hanleyhansen

    hanleyhansen New Member

    Joined:
    Jan 24, 2008
    Messages:
    336
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Drupal Developer/LAMP Developer
    Location:
    Clifton
    Home Page:
    I recommend using PHP's PDO or mysqli instead of mysql_connect as mysql_connect won't be supported for long and the community has already begun the deprecation process.
     
  5. The Alchemist

    The Alchemist New Member

    Joined:
    Jul 7, 2012
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for the suggestion guys... I realised that its normally given on the hosting sites... Anyways, thanks for helping...
     

Share This Page