SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am having a problem getting my PHP script to connect to my database. Here is what I am using for the script

    <HTML>
    <HEAD>
    <TITLE> My Database </TITLE>
    <HEAD>
    <BODY>
    <?php
    $dbcnx = @mysql_connect("localhost",
    "mysql", "mypasswd");
    if (!$dbcnx) {
    echo( "<P>Unable to connect to the " .
    "database server at this time.</P>" );
    exit();
    }
    ...
    ...
    ...
    </BODY> </HTML>

    I always get the unable to connect message whenever I try to access this page. What could the problem be? I know the server is running because I can do a telnet localhost 3306 and it responds with a not allowed to log in message.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a user named mysql in the user table?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that the perl script utility mysql_setpermission? I have added the user in there.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you just try

    > mysql -u root

    from the command line?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It gives me a Access Denied for user: root@localhost error message. I can do it with -u mysql though.

  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)
    Try removing the @ from your code so that you can see the exact error message that is produced.
    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 Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Upon removing the @ from my code I received this.

    Warning: MySQL Connection Failed: Access denied for user: 'datatest@localhost' (Using password: YES) in /usr/local/httpd/htdocs/datatest.php3 on line 8

  8. #8
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it, not sure what fixed it but all seems to work now.

    Thanks All


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
  •