Cannot connect to database live :(

Discussion in 'MySQL' started by Misanthr, Sep 29, 2009.

  1. #1
    This works fine localhost but without a password and user as root
    Wanted to get my site running and I run into an issue I never ever had before but it has been a long time since i played with a website

    
    <?php
    $ip=$_SERVER['REMOTE_ADDR'];
    $title = 'MansonQuotes.com';
    $host='misanthr';
    $username='misanthr_MQuotes';
    $password='password_removed';
    $db_name='misanthr_mansonquotesDB';
    $time=date("U");
    $date=date('m/j/y g:i:s A');
    mysql_connect($host,$username,$password)or die('cannot connect'); 
    mysql_select_db(misanthr_mansonquotesDB)or die('cannot select DB');
    ?>
    
    PHP:
    above is my exact config file except the password is removed. I am hosting off someone.

    When I try to connect, I get a long delay then this error

    Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'misanthr' (4) in /home/misanthr/public_html/config.php on line 10
    cannot connect

    What am I doing wrong?

    EDIT: Im taking to my host and he thinks its some code on his end hes looking into. I am sure its not my end
     
    Last edited: Sep 29, 2009
    Misanthr, Sep 29, 2009 IP
  2. ErikTheRed

    ErikTheRed Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Error code 4 is an Interrupted system call, so there is probably a firewall issue somewhere.
     
    ErikTheRed, Sep 29, 2009 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Where is your database hosted? Is it on the same machine where you are running PHP code? If this is the case, then replace
    $host='misanthr';
    with
    $host='localhost';

    Another change you should do is use $db_name in mysql_select_db().

    mysql_select_db($db_name)or die('cannot select DB');
     
    mwasif, Oct 1, 2009 IP
  4. thebillkidy

    thebillkidy Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try to remove the space here $title = 'MansonQuotes.com';
    so you get $title ='MansonQuotes.com';
     
    thebillkidy, Oct 14, 2009 IP