Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012

    Unanswered: Godaddy database connection error ...

    Hi everyone,

    I am having a bigg problem and I am completely at loss here ..

    I am trying to connect to the godaddy database (MYSQL Database)

    I have worked with the code on my local machine n it was working perfectly. But on the website the database connection just isnt happenening ..

    Please help me sumone ..

    My code is:
    PHP Code:
    $username "user";
    $dbname "db";
    $password "pass";
    $usertable "table";


    $query "SELECT * FROM $usertable";
    $result mysql_query($query);

    $row mysql_fetch_array($result))
    "loginid: " $row["loginid"];
    online link: Test Go Daddy Connection

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    consider using the or die statement to find out what errors are being reported
    you should really be using a different mechanism to connect to the DB, try mysqli. mysql was deprecated years ago and as such is not guaranteed to be available in the future

    in the above reference you will see two metholds
    mysqli::$errno — Returns the error code for the most recent function call
    mysqli::$error — Returns a string description of the last error
    which will tell you why the MySQL isn't working.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2009
    San Sebastian, Spain
    healdem is right. You really need to test the results of your functions and to display the error messages. If mysql_connect fails you continue to call the next function. When your process completes you will not know where your error actually occurred. You may end up thinking that it was the SQL statement that failed when it could have been the connection.

    Also mysql, though it has been deprecated, is still supported but again you should have a look at migrating away from this. An alternative to mysqli is PDO which allows you to eventually change the database driver without having to change your code. This way your code can work on MySQL, PostgreSQL, SQL Server, Oracle without any changes (that's the theory, the practice is that there is always something that would need to be changed but these would be minimal).
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    Follow me on Twitter

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts