ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    PHP Mess up

    IT Discussion
    php
    3
    6
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sparkum
      last edited by Sparkum

      Hey guys.

      So I'm still fairly new to the website world, my friend gave me some code that was working perfectly, I thought I only cut and pasted a piece of code, found it didnt work, and put it back. Obviously I may have done something else though?

      	// LOOP
      if ( $ocquery->have_posts() ) : while ( $ocquery->have_posts() ) : $ocquery->the_post(); 
      $content = preg_replace('/(<)([img])(\w+)([^>]*>)/', '', $content);
      $content = get_the_title();
      $content = apply_filters('the_content', $content);
      $content = str_replace(']]>', ']]&gt;', $content);
      $url = get_permalink();
      $img = get_the_post_thumbnail($the_post->ID, 'thumbnail');
      
      			
      			printf ('<li><div class="slide"> %s  <a href="%s"><input class="bluebutton blue" type="button" value="Click here to see this post!" />%s</a> </div></li>', $content, $url, $img,; ) 		endwhile;
      			
      endif;
          echo '</ul></div></div></div></div>';
      wp_reset_query(); // reset the query 
      

      Would anyone be able to tell me where my "whoopsie" is, what I did was remove the $img, and try to put it infront of the $url, then put it back (obviously wrong though)

      Thanks much appreciated.

      1 Reply Last reply Reply Quote 0
      • MattSpellerM
        MattSpeller
        last edited by MattSpeller

        Disclaimer: Don't know squat about PHP
        Careful when copy/paste code, it can copy the formatting and introduce errors. If using windows I think you can eliminate this by copying with........ I'll google it and edit in a sec.

        switch from using CTRL+V (Paste) to CTRL+SHIFT+V (Paste Plain Text).

        http://www.howtogeek.com/186723/ask-htg-how-can-i-paste-text-without-the-formatting/

        1 Reply Last reply Reply Quote 0
        • S
          Sparkum
          last edited by

          Using This Website I feel it should be a 3 second fix but I cant seem to get it?

          1 Reply Last reply Reply Quote 0
          • S
            Sparkum
            last edited by

            Bah got it

            printf ('<li><div class="slide"> %s <a href="%s"><input class="bluebutton blue" type="button" value="Click here to see this post!" />%s</a> </div></li>', $content, $url, $img ); endwhile;

            1 Reply Last reply Reply Quote 0
            • tonyshowoffT
              tonyshowoff
              last edited by tonyshowoff

              Put five ~ on a line above and below your code to properly format it, otherwise it's basically unreadable on this forum since Markdown will try to parse PHP symbols into formattable text.

              S 1 Reply Last reply Reply Quote 0
              • S
                Sparkum @tonyshowoff
                last edited by

                @tonyshowoff

                Ah that looks much prettier, thanks for the tidbit of advice

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post