mysql connection problem.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thallasridevi
    New Member
    • Dec 2007
    • 27

    mysql connection problem.

    when i am trying to connect to mysql from my php page i got the below message
    Warning: mysql_connect() : Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/d/e/a/dealersmax/html/db.php on line 6

    Warning: mysql_select_db (): supplied argument is not a valid MySQL-Link resource in /home/content/d/e/a/dealersmax/html/db.php on line 7

    I am using the below php code
    Code:
    <?php
    $conn1 = mysql_connect("localhost","username","password");
              $db1=mysql_select_db("database",$conn1);
              ?>
    can anyone please tell me how can i solve this?
    Last edited by Markus; Nov 3 '08, 10:32 AM. Reason: added # tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Add some or die() handlers to your queries.

    Code:
    mysql_query($query) or die(mysql_error());

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      There might be couple of reasons for this: the server is down, the database password was changed, the server has changed name, the communication between web server and database server is disturbed by a firewall. anyway your coding is good to use, but make sure to trap your errors always.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi.

        The error you posted is typically shown when you try to connect to a Linux based MySQL server that is not yet running.

        Make sure the MySQL server is in fact running on your server.

        Comment

        Working...