Parse Error Line 18

Discussion in 'PHP' started by fmjames, Jun 10, 2011.

  1. #1
    Hello!

    Just made an script and its giving me a error!

    
    Parse error: syntax error, unexpected T_VARIABLE in /home/clanessc/public_html/highranks/index.php on line 18
    
    Code (markup):
    Ok,

    Heres my full script

    <HTML>
    <BODY>
    <!--set up the table -->
    <TABLE BORDER="1" CELLPADDING="5">
    <TR>
    <TH>Report ID:</TH>
    <TH>Highrank Username:</TH>
    <TH>Username Demoted:</TH>
    <TH>Rank Before Demotion:</TH>
    <TH>Rank After Demotion:</TH>
    <TH>Date:</TH>
    <TH>Time:</TH>
    <TH>Reason:</TH>
    </TR>
    <?
    include 'includes/config.php'
    // This builds and executes the insert query
    $select = "SELECT ID, hr, ud, rb, ra, dat, time, reason 
    FROM tbl_demologs";
    $result = mysqli_query($link, $select);
    
    // This loops through results and fills table!
    while ($row = mysqli_fetch_array($result)) {
    // Get element  and put into an varible
    $ID = $row['ID']
    $hr = $row['hr']
    $ud = $row['ud']
    $rb = $row['rb']
    $ra = $row['ra']
    $dat = $row['dat']
    $time = $row['time']
    $reason = $row['reason']
    
    
    // This prints out our little code for each row!
    echo <<<END
    <TR>
     <TD>$ID</TD>
     <TD>$hr</TD>
     <TD>$ud</TD>
     <TD>$rb</TD>
     <TD>$ra</TD>
     <TD>$dat</TD>
     <TD>$time</TD>
     <TD>$reason</TD>
    </TR>
    END;
    }
    ?>
    <!-- Close table -->
    </TABLE>
    </BODY>
    </HTML>
    Code (markup):
    And my config.php here

    <?
    $link =
    mysqli_connect('clan-ess.co.uk','clanessc_high','Root','PassRemovedSecurityReasons');
    ?>
    Code (markup):
    Can anybody please help me fix this error =D?

    Thanks,
    James
     
    fmjames, Jun 10, 2011 IP
  2. dazst

    dazst Active Member

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #2
    change:
    
    include 'includes/config.php'
    
    Code (markup):
    to
    
    include 'includes/config.php';
    
    Code (markup):
     
    dazst, Jun 10, 2011 IP
  3. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks so much!
     
    fmjames, Jun 10, 2011 IP
  4. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    One more error...


    Parse error: syntax error, unexpected T_VARIABLE in /home/clanessc/public_html/highranks/index.php on line 26
     
    fmjames, Jun 10, 2011 IP
  5. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Can anybody help me with the above error Please?

    BUMP
     
    fmjames, Jun 10, 2011 IP
  6. mpa360

    mpa360 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You should use " ; " in the end of each command.

    Change these lines :

    $ID = $row['ID'];
    $hr = $row['hr'];
    $ud = $row['ud'];
    $rb = $row['rb'];
    $ra = $row['ra'];
    $dat = $row['dat'];
    $time = $row['time'];
    $reason = $row['reason'];
    PHP:
     
    mpa360, Jun 10, 2011 IP
  7. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Another one :S

    I checked the script but i dont get whats wrong !?
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/clanessc/public_html/highranks/index.php on line 23

    and thanks mpa
     
    fmjames, Jun 10, 2011 IP
  8. mpa360

    mpa360 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Database is empty, SQL is wrong or database connection problem

    add this code :

    echo 'Error : ' . mysql_error($link);
    PHP:
    After this :

    $result = mysqli_query($link, $select);
    PHP:
    And look what says
     
    mpa360, Jun 10, 2011 IP
  9. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Error : Table 'clanessc_hsystem.tbl_demologs' doesn't exist

    clanessc_hsystem and tbl_demologs DO exist :S
     
    fmjames, Jun 10, 2011 IP
  10. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #10
    syntactically it should be :

    mysqli_connect('localhost', 'my_user', 'my_password', 'my_db');
    PHP:
    as per http://www.php.net/manual/en/mysqli.connect.php

    So in your case :

    mysqli_connect('clan-ess.co.uk','clanessc_high','Root','PassRemovedSecurityReasons');
    PHP:
    (u have changed the order before posting?)

    you are selecting db name as "clanessc_high"

    and your error shows "clanessc_hsystem"

    sorry if m incorrect but i got a bit confused! :?
     
    niks00789, Jun 12, 2011 IP
  11. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    No,

    Host = clan-ess.co.uk
    Username = clanessc_high
    Database Name = clanessc_hsystem
    Password =
     
    fmjames, Jun 14, 2011 IP
  12. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #12
    try this query instead :

    
    $select = "SELECT ID, hr, ud, rb, ra, dat, time, reason 
    FROM clanessc_hsystem.tbl_demologs";
    
    PHP:
    and see if it helps
     
    niks00789, Jun 14, 2011 IP
  13. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Still getting error

    Error : Table 'clanessc_hsystem.tbl_demologs' doesn't exist
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/clanessc/public_html/highranks/index.php on line 24
     
    fmjames, Jun 15, 2011 IP
  14. fmjames

    fmjames Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Problem fixed
     
    fmjames, Jun 15, 2011 IP