mysql_connect woes

    Date: 06/23/06 (PHP Community)    Keywords: php, mysql, asp, sql

    I have a very simple script set up to verify weither or not I can connect to mySQL from a PHP script.

    <?php
    $link = mysql_connect('localhost', 'root', 'XXXXXXXX');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>

    I recieve the following error:

    Could not connect: Can't connect to local MySQL server through socket '/var/mysql/tmp/mysql.sock' (13)


    I tried replacing 'localhost' with 127.0.0.1 .

    Now I have a completely different error message:

    Could not connect: Lost connection to MySQL server during query


    First of all I'd like to know why I can't just use 'localhost' and second, I'd like to get this damn thing to work! I'm really frustrated. I hope someone can help. I've searched all over the internet for a solution to my problem but am having no luck. mySQL is running fine, and the mysql.sock file is there where it should be. I can also log in from the command line. I am exasperated!


    I am running Slackware 10, mySQL 5.0.21-log, and PHP 4.4.2.


    Any ideas helping me out would be much appreciated. I need this to work!

    Source: http://community.livejournal.com/php/463943.html

« cURL support/check || What is this doing? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home