SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: localhost

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    localhost

    is there a way to view the contents of "localhost"?

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not quite sure what you mean. "Localhost" is a hostname, just like yahoo.com, except it always represents the computer you are currently on.

    Do you want to see http://localhost/ , or the contents of the mySQL DB at 'localhost', or what?

    To see what mySQL has, just do: mysql -u <username> -p, if that's what you want.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nah.. i just want to find out what localhost represents when you are connecting to a database.. is it a IP? I know its the host the script is being run from, but I am having troubles connecting to a mysql server on host A when running a script from host B

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Localhost represents 127.0.0.1, an IP. That IP is commonly referred to as the 'loopback' IP, because no matter what computer you're using, it'll always represent the current computer.

    By default, mySQL connects to localhost. To connect to another one, do: mysql -u <username> -p -h <hostname>. Not sure how to do it in PHP, but it's an argument to mysql_connect().

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_connect("xxx.xxx.xxx.xxx", "username", "password
    ');

    xxx.xxx.xxx.xxx is the ip address.

  6. #6
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How could I find out what ip localhost is using when I connect to the database

  7. #7
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Localhost is always 127.0.0.1, if that's what you're asking.

  8. #8
    SitePoint Wizard
    Join Date
    Apr 2000
    Posts
    1,483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to connect to a MySQL database on localhost using PHP, just use this command:

    PHP Code:
    <?php
    mysql_connect
    ("localhost""username""password");
    ?>
    And that's all there is to it it will work out the IP etc without any more help.

  9. #9
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know hos to connect to a server..


    I have a database on server A
    now, I have the php scripts that need to connect to server A.
    the php scripts are not on the same server that have the database, so I can use local host.... I can run scripts on the server that has the database to find out what the addy for that host is, but the bulk of the scripts have to be on a seperate server

  10. #10
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by slighltywhacked

    the php scripts are not on the same server that have the database, so I can use local host....
    If the scripts are not on the DB server, then you can't connect to the localhost mySQL DB--there isn't one. Instead you would need to substitute the DB server's hostname for 'localhost'.

    Ask your host what their DB server's hostname is.

  11. #11
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if I run a server on my own computer, how can I figure out the IP I should give people to reach my site?
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  12. #12
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you set it up, it should tell you or you specify one.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •