Parse error: syntax error, unexpected '{'

Discussion in 'PHP' started by peter_anderson, Jul 18, 2009.

  1. #1
    Hi,

    I am getting the following error: "Parse error: syntax error, unexpected '{' on line 38" but I cannot see what is causing it.

    Any ideas?

    Here is my full code:
    <?php
    
    //get required files
    //config
    require_once("config.php");
    //theme
    $html = file_get_contents('./theme/theme.html');
    
    //get page
    $pg = $_GET['page'];
    
    //connect to DB
    mysql_connect($host, $user, $pass) or die(mysql_error());
    mysql_select_db($db) or die(mysql_error());
    
            //query
            $query = mysql_query("SELECT * from `pages` WHERE pagen='$pg'") or die(mysql_error());  
            // Perform Query
            $row = mysql_fetch_array($query);
    
    $html = str_replace('{content}', $row['content'], $html);
    
    $html = str_replace('{title}', $row['title'], $html);
    
    $html = str_replace('{footer}', @file_get_contents('./articles/footer.txt'), $html);
    $html = str_replace('{sidebox}', @file_get_contents('./articles/sidebox.txt'), $html);
    $html = str_replace('{mainlinks}', @file_get_contents('./articles/mainlinks.txt'), $html);
    $html = str_replace('{headerlinks}', @file_get_contents('./articles/headerlinks.txt'), $html);
    
    $news = '<ul>';
    $newsq1 = "SELECT * from `news` ORDER by id DESC";
    $newsq = mysql_query($newsq1);
    while ($row2 = mysql_fetch_array($newsq)) {
    $news .= '        <strong><a href="/page/news/202,'.$row2['id'].'">'.$row2['title'].'</a></strong><br />
            '.$row2['teaser'].'</li>';
    }
    $news = '</ul>';
    
    $html = str_replace{'{newslist}', $news, $html);
    
    $html = str_replace('{clubname}', '', $html);
    $html = str_replace('{worldmenu}', '', $html);
    $html = str_replace('<h2>', '<h2 class="title>', $html);
        
    # Output Content
    echo $html;
    ?>
    Code (php):
     
    peter_anderson, Jul 18, 2009 IP
  2. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yup, little typo you had:

    $html = str_replace{'{newslist}', $news, $html);
    ^^^

    $html = str_replace('{newslist}', $news, $html);
     
    Goramba, Jul 18, 2009 IP
    peter_anderson likes this.
  3. peter_anderson

    peter_anderson Notable Member

    Messages:
    3,382
    Likes Received:
    152
    Best Answers:
    0
    Trophy Points:
    240
    #3
    Thanks!

    Can't believe it was something so simple :)

    +rep added.
     
    peter_anderson, Jul 18, 2009 IP