SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can't connect to mysql server through php

    hi all
    i'm using the sitepoint book and installed php on iis
    but i'm having problems with this line

    prompt
    PHP Code:
    $dbConn = @mysql_connect('localhost''root''mypassword');
        if (!
    $dbConn) {
            echo(
    '<p>Unable to connect to the database server at this time.</p>');
            exit();
        } 
    name is definitely localhost,
    root, and password are definitely right,
    i can connect in the command prompt and edit and stuff
    but i always get the error message
    i've tried removing the @ symbol, but i still get my own message
    i installed php and mysql exactly the same as in the book
    in different directories but i don't think that would be the problem

    anyone know what could be wrong
    i can do other php, just can't connect to the mysql server

    thanks

  2. #2
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Modify the first line to display the error being generated.
    PHP Code:
    $dbConn = @mysql_connect('localhost''root''mypassword') or die(mysql_error()); 
    Having the error code will assist in determining the problem.
    Lats...

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for that
    i didn't know how to write out the error
    i'm at work at the moment, but i'll try tonight
    and post the message then
    thanks again

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unknown MySQL Server Host 'localhost' (11001)
    but i have mysql control centre and it connects to localhost

    and i connect in the cmd prompt and it says localhost

  5. #5
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ummm, it certainly looks like the normal way of connecting to a db.

    Doing a google on that error number wasn't very helpful
    Lats...

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i buy this book
    and it turns out to be useless
    it's all good and well that i can read through
    but if i can't use it practically
    then it's just not useful

  7. #7
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works well for me on my local linux box, and my live server, so possibly a configuration problem??
    Lats...

  8. #8
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the only difference from the book i have
    is where i installed mysql and php
    but i changed the my.ini file to match
    i installed mysql on my personal drive
    where i have iis and php running from
    do you think i should try uninstalling mysql
    and reinstalling it into the program files dir?

    oh and mysql-nt.exe is definitely running
    Last edited by dtra; Jul 24, 2003 at 00:13.

  9. #9
    SitePoint Evangelist
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very strange
    now for some reason it works
    i checked it on my other computer over the network
    and the page worked, and now for some reason it
    will connect to mysql, i hope it's not because i'm
    connected to the internet
    cos i'm on dialup, and i don't want to connect
    everytime i want to check something


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
  •