GoDaddy mySQL/PHP Problem

Discussion in 'Web Design and Development' started by MacDonaldsd, Aug 12, 2007.

  1. MacDonaldsd macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #1
    Im having a problem with connecting to my mySQL database via PHP. I modified GoDaddy sample PHP script:

    <?php
    //Sample Database Connection Syntax for PHP and MySQL.

    //Connect To Database
    $hostname="mysqladmin2.secureserver.net";
    $username="anotherdatabase";
    $password="*****";
    $dbname="anotherdatabase";
    $usertable="music";
    $yourfield = "artist";



    mysql_connect($hostname,$username,$password);
    mysql_select_db($dbname);

    # Check If Record Exists

    $query = "SELECT * FROM $usertable";

    $result = mysql_query($query);

    if($result)
    {
    while($row = mysql_fetch_array($result))
    {
    $name = $row["$yourfield"];
    echo "Name: ".$name."
    ";
    }
    }
    ?>


    And I get the error

    Warning: mysql_connect(): Lost connection to MySQL server during query in (the URL) on line 15

    Which is: mysql_connect($hostname,$username,$password);
     
  2. Winterfell macrumors regular

    Joined:
    Apr 3, 2007
    Location:
    Tulsa, Oklahoma
    #2
    If you're not receiving any errors when you connect, then it looks like the connection is happening perfectly fine.

    If you're losing connection during the query, it almost sounds like it's a problem with your MySQL server provider. You might contact them and see if they can help you.
     
  3. X1Lightning macrumors 6502

    X1Lightning

    Joined:
    Feb 19, 2007
    #3
    Is your Mysql DB hosted at godaddy? i use them for one of my servers, and i tried to use a mysql db at a different host, i couldn't get it to work right, so i ended up moving the db to godaddy
     
  4. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #4
    The problem was with the $hostname they gave me a different one to use.

    On a side note it won't work with the mysqli function at all.
     

Share This Page