#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    1
    Rep Power
    0
    Hi !

    I am having problem on connecting to my MySQL Server.

    I have Redhat 6.2 Linux Server with PHP4 and MySQL.

    i have written a simple code :

    $link = mysql_connect("localhost","username","password") or die("error");

    and it gives me error like :

    Warning: MySQL Connection Failed: Can't connect to local MySQL server
    through socket '/tmp/mysql.sock' (111)

    Do you know why it gives an error like this ?

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    15
    im just guessing, but you need more than that.. like your database name and something to send sql. Try this.

    $str_sql = "show tables";
    $id = @mysql_connect('localhost', (username), (password);

    $result = mysql_db_query((dbname), $str_sql, $id);

    althought now that i think of it you should be able to just do a:

    if ($id) {
    echo 'it worked';
    }
    else {
    echo 'it didnt work';
    }


    dunno mess around heh

    sam

Similar Threads

  1. Custom error message for MySQL connection
    By dbr1066 in forum PHP Development
    Replies: 6
    Last Post: February 12th, 2004, 11:25 AM
  2. DreamWeaver MX and MySQL problem!!
    By genog in forum MySQL Help
    Replies: 3
    Last Post: February 12th, 2004, 06:57 AM
  3. java / mysql connection
    By johann8401 in forum Java Help
    Replies: 2
    Last Post: February 9th, 2004, 12:27 PM
  4. mysql server looses connection
    By Webbgroup in forum MySQL Help
    Replies: 1
    Last Post: January 29th, 2004, 11:19 AM
  5. mysql problem with joining tables , complicated!
    By toxical in forum PHP Development
    Replies: 6
    Last Post: January 27th, 2004, 03:43 PM

IMN logo majestic logo threadwatch logo seochat tools logo