SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Mar 2001
    Location
    Ottawa, Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_connect('help!!')

    I write:
    mysql_connect('localhost', 'root', 'password')

    which works fine, but I want to reference the IP number instead referencing localhost, like so:
    mysql_connect('111.222.333.444', 'root', 'password')

    and this doesn't work!!!! why

    This has been bothering me for a few days now, and I need to get this fixed, it is driving me insane!!

    if you can help me, you'll be my hero!!!
    thanks,
    brennen

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Los Angeles, California
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try using double quotes (") instead of the single quotes
    www.iyeinteractive.com - Website Design and Programming
    www.totalnonsense.net - my site, Under Construction

  3. #3
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to know the IP for localhost? That's always 127.0.0.1, so the code'll be:
    PHP Code:
    mysql_connect ("127.0.0.1","root","C0ol"); 

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to access a mysql server on another computer over a network. php/mysql won't allow this under the default settings. You gotta mess with something to get that to work. Don't know what though off the top of my head.

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to make sure that your user has access to access the database from a remote server. In your database in the mysql database > user table

    For instance if root needs to access the database from a remote server(keep in mind opening up root privileges outside the localhost is not advised(sp?)) but this is what it would look like

    mysql> select * from user;
    +-----------+-----------------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
    | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
    +-----------+-----------------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
    | % | root | *********** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |



    Notice the Host column is set to %, this means okay from any host. Just make sure your user has the right permissions. Chances are right now it says localhost in that column which means this user can only connect from localhost in other words the computer where the script is living.
    Last edited by freddydoesphp; Jun 19, 2001 at 19:44.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here's the section of my PHP/MySQL series that coveres these idiosynchrasies of MySQL's access control system:

    http://www.webmasterbase.com/article.php/228/968
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a descripancy between those last two answers? I thought Kyank's article said to set-up two users, whereas, freddydoesphp says to use the % wildcard.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  8. #8
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was having a similar problem of only being able to connect using localhost. I changed my user info to "%" instead of "localhost" and now it lets me connect as 127.0.0.1, but not as my actual IP address "http://24.10.xx.xx" (I'm on a cable modem I can reach my computer from outside via this IP with IIS or Apache running).
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Read the section of my article referenced above closely. The problem actually stems from two default entries in the 'user' table that should almost always be removed on a production system!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


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
  •