• When I add a hack to the my-hacks.php file I get the following error:
    Parse error: parse error, unexpected T_FUNCTION in /home/shear/public_html/wordpress/my-hacks.php on line 3
    What is going on? Can anyone help?
    Thanks, David.

Viewing 10 replies - 1 through 10 (of 10 total)
  • It might be helpful to know what is on that line. Sometimes this is due to a missing semi-colon from the previous line(s). In this case it looks like it found something it wasn’t expecting in a place where it wasn’t supposed to be. If you post lines 1 – 5 of you file, I could give you a more difinitive answer.
    TG

    Thread Starter Anonymous

    Ok, the first 5 lines of the hack I was trying to install are below:
    function comment_plugger($before = ”, $limit = 5, $sep = ‘, ‘) {
    global $wpdb, $tablecomments, $id;
    $request = “SELECT comment_author, comment_author_url, MAX(comment_ID) as comment_ID FROM $tablecomments”;
    $request .= ” WHERE comment_post_ID=’$id’ AND comment_approved = ‘1’ GROUP BY comment_author, comment_author_url ORDER BY comment_ID DESC”;
    I got the hack from http://wiki.wordpress.org/index.php/Comment%20Plugger
    Thanks, David

    I don’t see any errors in those 4 lines. Maybe try recopying the hack into my-hacks would be my only suggestion. I have the hack installed and it works fine.

    Thread Starter Anonymous

    I have tried doing that multiple times, I have noticed that it is doing it with every hack I try to install… every hack I try to install in my-hacks.php that error message comes up (or something simular). I am still getting:
    Parse error: parse error, unexpected T_FUNCTION in /home/shear/public_html/wordpress/my-hacks.php on line 2
    any more suggestions?

    What are you using to edit my-hacks? Make sure it is not Notepad.

    Thread Starter Anonymous

    Exactly the same problem with line 2 or3
    here is the hack :
    <? php
    function get_recent_posts($no_posts = 5, $before = ‘

    • ‘, $after = ‘
    • ‘, $show_pass_post = false, $skip_posts = 0) {
      global $wpdb, $tableposts;
      $request = “SELECT ID, post_title FROM $tableposts WHERE post_status = ‘publish’ “;
      if(!$show_pass_post) { $request .= “AND post_password =” “; }
      $request .= “ORDER BY post_date DESC LIMIT $skip_posts, $no_posts”;
      $posts = $wpdb->get_results($request);
      $output = ”;
      foreach ($posts as $post) {
      $post_title = stripslashes($post->post_title);
      $permalink = get_permalink($post->ID);
      $output .= $before . ‘‘ . $post_title . ‘‘ . $after;
      }
      echo $output;
      }
      ?>
      I edited it with Edit Plus and Crimson… Any idea ?

    On the very first line, take out the space between the ? and the “php” part. I had the very same problem you had and once I took that space out, that fixed my problem. 🙂

    Gosh ! Thanks Dansgirl165 ! That was it 😉

    You’re welcome. 🙂

    that space was so obvious i missed it, it’s the little things that get you, grrrrrrrrrrrrrrrrr

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Error with my-hacks.php’ is closed to new replies.