SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can't find parse error

    Supposedly there is a parse error in the first line

    PHP Code:
    } elseif($_GET['do']=="3") {
        
    $Query "SELECT id, Pages FROM $TableName";
        
    $Result mysql_db_query ($DBName$Query$Link); 
        while (
    $Row mysql_fetch_array ($Result)) {
     echo
    '
    <a href="pages.php?do=4&amp;id='
    .$Row[id].'">['.$Row[id].'] | '.$Row[Page].'</a><br>
    '
    ;

    Parse error: parse error, unexpected '}' in C:\webap\xampp\htdocs\v4\admin\pages.php on line 48
    I have tried removing the } but that just causes more problems, and I don't see why it should be removed.

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the error is caused by something ABOVE that line. maybe you missed a semicolon or a closing ' or " . It happens all the time. PHP cant parse the } coz it's expecting some stuff for the code.


    can you post a couple of the lines above the } in the first line above?

  3. #3
    SitePoint Zealot itsyM's Avatar
    Join Date
    Jul 2002
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Possibility
    PHP Code:
    } elseif($_GET['do']=="3") {
        
    $Query "SELECT id, Pages FROM $TableName";
        
    $Result mysql_db_query ($DBName$Query$Link); 
        while (
    $Row mysql_fetch_array ($Result)) {
     echo
    '
    <a href="pages.php?do=4&amp;id='
    .$Row[id].'">['.$Row[id].'] | '.$Row[Page].'</a><br>
    '
    ;

    You have not closed the while-loop. Missing }

  4. #4
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I closed the while loop, same problem. Here is more of my code:

    PHP Code:
    <?

    if($_GET['do']=="1") { //Submit the data
        
    echo
            
    '
        <form action="pages.php?do=2" method="post">
            <input type="text" name="Page" size="30"> | Page Title <br><br>
            <textarea rows="25" cols="85" name="Body"></textarea> <br><br>
            <input type="submit" value="Submit">
        </form>
            '
    ;
    } elseif(
    $_GET['do']=="2") {
        
    //Trim the incoming data
        
    $Body trim($_POST['Body']); 
        
    $Query "INSERT into $TableName values ('0', '$Page', '$Body')";

    if (
    mysql_db_query ($DBName$Query$Link)) {
         print (
    "The query was successfully executed!<BR>\n");
    } else {
         print (
    "The query could not be executed!<BR>\n");

    mysql_close ($Link);
    } else {
        echo
            
    '
        Not a valid do statement, please try again.
            '
    ;
    }
    //Select which page to edit
    } elseif($_GET['do']=="3") {
        
    $Query "SELECT id, Pages FROM $TableName";
        
    $Result mysql_db_query ($DBName$Query$Link); 
        while (
    $Row mysql_fetch_array ($Result)) {
     echo
    '
    <a href="pages.php?do=4&amp;id='
    .$Row[id].'">['.$Row[id].'] | '.$Row[Page].'</a><br>
    '
    ;
    }
    }
    ?>

  5. #5
    SitePoint Zealot itsyM's Avatar
    Join Date
    Jul 2002
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Possibility
    PHP Code:

    } <- REMOVE THIS
    //Select which page to edit
    } elseif($_GET['do']=="3") { 
    You have one } too much.

  6. #6
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That just produces a T_ELSEIF parse error.

    That } was closing off this echo statement:

    PHP Code:
    else {
        echo
            
    '
        Not a valid do statement, please try again.
            '
    ;

    The above being a sub-if/elseif statement inside the handle data if statement, dealing with the MySQL result.

    EDIT: I tried closing off the elseif statement and starting another if statement, and it seems to be working fine now.

  7. #7
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please, just count the { and } or get a editor which does it for you.

  8. #8
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doh! I found the error. I tried putting that elseif statement after an } else { statement, mistaking it for something else


Bookmarks

Posting Permissions

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