anyone know what might be wrong?

Discussion in 'PHP' started by AMFsound, Oct 24, 2008.

  1. #1
    Hi guys,

    I tried to load content to my host. It successfully uploaded, but I get a white page when I try to view the site. I can access the games on the site (it's basically a game site) by adding an extension on the end of the web address, so the site is active, but the front main landing page of the site is totally white, with nothing on it.

    When I tried to create an SQL database on my host, this is the finished product that was created(on the 4th line down, I replaced "your password" with my actual password) and I uploaded what you see as the config php file to my host;


    <?php
    //Connect To Database
    $hostname='p41mysql181.secureserver.net';
    $username='wintersdan';
    $password='your password';
    $dbname='wintersdan';
    $usertable='your_tablename';
    $yourfield = 'your_field';


    mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
    mysql_select_db($dbname);

    $query = 'SELECT * FROM $usertable';
    $result = mysql_query($query);
    if($result) {
    while($row = mysql_fetch_array($result)){
    $name = $row['$yourfield'];
    echo 'Name: '.$name;
    }
    }
    ?>



    I see the middle blue section of the script indicates "for die" and also "unable to connect to database" I don't understand what would cause that, but it certainly does seem to indicate a problem.....any ideas?

    thanks..!
     
    AMFsound, Oct 24, 2008 IP
  2. cont911

    cont911 Peon

    Messages:
    50
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    code looks correct.
    regarding ... OR die(..) construction, php calculates logical operator 'xxx OR yyy' in the following way:
    - calculate xxx
    - if xxx is true (or can be converted to true), then stop calculation, entire OR construction is true
    - if not, calculate next opeand yyy

    so, if mysql_connect returns true, die will not be run

    you can convert this OR to if operator
    if(!mysql_connect (...))
    {
    die(...);
    }
     
    cont911, Oct 24, 2008 IP
  3. AMFsound

    AMFsound Peon

    Messages:
    187
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You certainly have a better grasp than I do, as I'm a novice.....

    are you suggesting I make any specific change?

    It was difficult for me to discern if you were...........but I did catch that you said
    "the code looks correct" any other suggestions if that is the case?

    I don't know how to proceed...
     
    AMFsound, Oct 24, 2008 IP
  4. Shoro

    Shoro Peon

    Messages:
    143
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If the die() is executing. It means that the MySQL connection isn't being established. Usually this means either the hostname, username, or password being used is wrong.
     
    Shoro, Oct 24, 2008 IP
  5. Equaite

    Equaite Active Member

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    1
    #5
    Try changing that blue line to this:

    mysql_connect($hostname,$username, $password) OR DIE (mysql_error());
    PHP:
    I replaced the string in die() with mysql_error(), which returns a MySQL error if one is registered. Do that and it will let you know the reason you can't connect. :)
     
    Equaite, Oct 24, 2008 IP
  6. AMFsound

    AMFsound Peon

    Messages:
    187
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks Shoro,

    the username and password I've verified...my host company verified the host name was correct


    Equaite,

    thanks for the suggestion. I did as you said, and this error was return on the main web page, instead of the previous blank or white display, the following was displayed;

    Parse error: parse error, unexpected '[' in /home/content/d/a/n/dannyboy1/html/config.php on line 10

    dannyboy1 is my username to access this specific hosting account
     
    AMFsound, Oct 24, 2008 IP
  7. Equaite

    Equaite Active Member

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    1
    #7
    Recheck my post, I had made a typo that caused the PHP code highlighter not to work. :eek:
     
    Equaite, Oct 25, 2008 IP