SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unexpected T_ELSE

    Hello,

    Can someone take a peek at this code and tell me why I get an "Unexpected T_ELSE" parse error?

    Thanks.

    Code:
    <?php
    $db_server_connect=@mysql_connect("localhost","cybercor_root");
    if(!$db_server_connect):
    ?>
    <div id="bold">
    I'm sorry, but the database server appears to be offline. Please try again later.
    </div>
    <?php else: ?>
    <?php
    $db_connect=@mysql_select_db("writings");
    if(!$db_connect):
    ?>
    <div id="bold">
    I'm sorry, but the writings database could not be located. Please try again later.
    </div>
    <?php else: ?>
    $writings=@mysql_query("select type,title,description from writings");
    if(!$writings):
    ?>
    <div id="bold">
    I'm sorry, but the writings could not be located within the database. Please try again later.
    </div>
    <?php else: ?>
    <?php
    while($writing=mysql_fetch_array($writings)):
    ?>
    <div id="bold"><?php echo"$writing[\"title\""; ?>(<?php echo"$writing[\"type\""; ?>)</div>
    <div id="paragraph">
    <?php echo"$writing[\"description\""; ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    <?php endif; ?>
    <?php endif; ?>
    Once again, thanks.

    compuwhiz7

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of the if statements you could also add a "or die('error message'); to the the mysql_* stuff.

    PHP Code:
    $db_server_connect=@mysql_connect("localhost","cybercor_root" ) or die('Could not connect'); 
    Then you can remove the if statements.

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Compuwhiz,

    It would be MOST helpful if you would indicate which line the error is pointing to.
    John

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP John
    Compuwhiz,

    It would be MOST helpful if you would indicate which line the error is pointing to.
    It appears to be line 49. Sorry about the confusion.

    Compuwhiz7

  5. #5
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php else: ?>

    you don't end the first if statement before else:
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, everyone!


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
  •