1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Tstring error. What's the problem ?

Discussion in 'PHP' started by bondigor69, Dec 21, 2013.

  1. #1
    I can't get it, it was working fine and now I get this error ??????

                                  <?php
    if (has_tag()) {
    $tags = get_the_tags();
    $html = '<div class="post_tags" onclick="javascript:_gaq.push(['_trackSocial', 'Tags', 'Related']);"><div id="tags">Tagged : </div>';
    foreach ( $tags as $tag ) {
        $tag_link = get_tag_link( $tag->term_id );       
        $html .= "<div  id="tags"><a href='{$tag_link}' title='{$tag->name}' >";
        $html .= "{$tag->name}</a></div>";
    }
    echo $html;
    }
    else {}
    ?>
    </div>
    PHP:
     
    bondigor69, Dec 21, 2013 IP
  2. aliaydin

    aliaydin Greenhorn

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    23
    #2
    you shold use like this
    ([\'_trackSocial\', \'Tags\', \'Related\'])
    PHP:
    i hope this helps
     
    aliaydin, Dec 21, 2013 IP
  3. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #3
    ThePHPMaster, Dec 21, 2013 IP
  4. bondigor69

    bondigor69 Greenhorn

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #4
    same thing
    syntax error, unexpected T_STRING on line 398

    If I remove this code everything works fine.
     
    bondigor69, Dec 22, 2013 IP
  5. Philbeng

    Philbeng Well-Known Member

    Messages:
    36
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #5
    It looks like your use of quotation marks both ' & " is wrong!
    Read the linked to page above paying particular attention to the part about escaping characters inside quoted strings. Good luck with it these kind of errors can take a age to sort also look at line 7 in the code above as that could give you errors.

    <?php
    if (has_tag()) {
    $tags = get_the_tags();
    $html = '<div class="post_tags" onclick="javascript:_gaq.push([\'_trackSocial\', \'Tags\', \'Related\']);"><div id="tags">Tagged : </div>';
    foreach ( $tags as $tag ) {
        $tag_link = get_tag_link( $tag->term_id );  
        $html .= "<div  id=\"tags\"><a href='{$tag_link}' title='{$tag->name}' >";
        $html .= "{$tag->name}</a></div>";
    }
    echo $html;
    }
    else {}
    ?>
    PHP:
    Don't know if that will help?
     
    Last edited: Dec 22, 2013
    Philbeng, Dec 22, 2013 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    Try this:
    
    <?php
       if (has_tag()) {
         $tags = get_the_tags();
         $html = '<div class="post_tags" onclick="javascript:_gaq.push([\'_trackSocial\', \'Tags\', \'Related\']);"><div id="tags">Tagged : </div>';
       foreach ( $tags as $tag ) {
        $tag_link = get_tag_link( $tag->term_id );   
        $html .= '<div  id="tags"><a href="'.$tag_link.'" title="'.$tag->name.'" >';
        $html .= $tag->name.'</a></div>';
       }
       echo $html;
       }
       else {}
    ?>
    
    PHP:
     
    PoPSiCLe, Dec 22, 2013 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Well, first off any script WORTH using should be attaching the js instead of using the onxxx methods :D

    Second, if you're just going to echo it out, why the blue blazes do you even have in in a variable in the first place?!? Waste of memory and processing time!

    Next, that LOOKS like it should be a heading, not a DIV... and that looks like a list of tags, not a bunch of DIV.

    Finally, if TITLE is identical to the text inside an element, there is only ONE legitimate reason to be wasting bandwidth on even HAVING a TITLE attribute on an element... and I don't see any accesskeys there!

    Assuming you want to use echo:
    if (has_tag()) {
    
    	echo '
    		<div
    			class="post_tags"
    			onclick="javascript:_gaq.push([\'_trackSocial\', \'Tags\', \'Related\']);"
    		>
    			<h2>Tagged :</h2>
    			<ul>';
    
    	$tags = get_the_tags();
    	foreach ( $tags as $tag ) echo '
    				<li>
    					<a href="', get_tag_link( $tag->term_id ), '">
    						', $tag->name, '
    					</a>
    				</li>';
    				
    	echo '
    			</ul>
    		<!-- .post_tags --></div>';
    
    } else {
    	/* assume you're doing something different here?!? */
    }
    Code (markup):
    Also, wouldn't it make more sense for that onclick to be on the anchors, instead of the entire div including the title?!?
     
    deathshadow, Dec 24, 2013 IP
    NetStar likes this.
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    It looks very much like Wordpress-code, and if it is, changing elements isn't always recommended, since the often prefix the CSS with type.
     
    PoPSiCLe, Dec 24, 2013 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #9
    Which is why 99% of the time every last drop of CSS on a turdpress theme (along with it's markup) should be thrown in the trash, since it's typically the pinnacle of ineptitude with the "Inheritance, what's that?" asshattery of throwing endless multiple classes at EVERYTHING in the markup doubling the code size for no good reason.

    Again, see the dipshit nonsense like:
    <div id="post-1" class="post-1 post type-post status-publish format-standard hentry category-uncategorized">
    Code (markup):
    or
    <a class="url fn n"
    Code (markup):
    or
    <div class="menu"><ul><li class="current_page_item"><a href="http://demo.opensourcecms.com/wordpress/" title="Home">Home</a></li><li class="page_item page-item-2"><a href="http://demo.opensourcecms.com/wordpress/?page_id=2">Sample Page</a></li><li class="page_item page-item-4"><a href="http://demo.opensourcecms.com/wordpress/?page_id=4">Tere</a></li></ul></div>
    Code (markup):
    Where if you don't know what's wrong with those, do the world a favor, back the **** away from the keyboard and don't come back until you do. :D

    To elaborate, endless pointless classes for nothing, and in that last one a DIV for nothing and pointlessly redundant TITLE attrubute as well! (as if UL isn't a perfectly good block level container?!?)

    Oh, I also noticed another problem with the original code...

    foreach
    id="tags"

    Do we see a problem here?
     
    deathshadow, Dec 24, 2013 IP
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    Yeah. It's pretty much garbage. However, dismissing Wordpress as "shit" is not doing the world a favor. Wordpress is, at its core (standalone install), the best ready-made CMS out there. Does that mean its good? Nope. But it means it's doable for "anyone" to set up and use, without hardcore code-knowledge. Does that mean there's a shitload of crappy webpages running Wordpress out there? Of course.
    The class-asshattery is horrible, but somewhat understandable - when you do not know the structure of any given installation, you can hardly access given elements based on inheritance, sequence or anything else more sane - you need to add code which sets the elements you need to adjust outside anything else similarily coded. Given, this mostly applies to plugins - the main structure of the plain Wordpress install is perfectly possible to make decent, if you bother making your own theme. (You can basically code your theme however you want it, including recoding built-in functions if need be).

    I remember a thing with the captioned images Wordpress used to output (maybe they still do) - a div within a div, usually placed randomly within p-tags etc. Had to rewrite the whole function to make a somewhat working semantically correct structure, and submitted the change, oh... I dunno, several versions ago. They still use the old code. Hence, Wordpress is possible to make ok, but you need to redo mostly everything (still, it's usually faster than coding anything similar from scratch).
     
    PoPSiCLe, Dec 25, 2013 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #11
    Bullcookies -- the only way that reasoning makes the least bit of sense is trying to use the same CSS for different markup, and that's such a completely bullshit asshat way of building a website anyone practicing that approach should be taken 'round back o' the woodshed and put down like Old Yeller.

    It is not "understandable" it is ineptitude that makes it harder to skin, harder to work with, and slower to deploy. Anyone telling you otherwise doesn't know enough to be opening their mouth on the subject!

    Excepting all the crap it shoves down your throat for markup completely outside the theming system (which is dumb as fried ****) that you basically have to either gut out of the core code (neutering your upgrade path) or post-process with regex (which is just SO efficient!). Turdpress 3 made it a bit better with the 'walker' objects, but that's a royal PITA like the rest of the idiotic skinning system that at this point, you couldn't pay me to work with.

    Admittedly three years ago I told four clients back to back who were insisting on using it to go **** themselves and find some other host. Been fun watching them fade into obscurity and two outright ceasing to exist because they didn't want to listen or learn.

    Much like a number of other web technologies that people sleaze along with, I've not seen a site done with it that was worth a flying purple fish with a green sea bass on a bed of rice. Purple fight green, green fight purple, there is no other way.
     
    deathshadow, Dec 25, 2013 IP
  12. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #12
    You're still too crass, Deathshadow. But hey, I'm getting there as well. However, saying that you haven't seen anything worth anything using WP, is a bit like saying Facebook is completely useless. It might be, for you, but that doesn't mean that thousands of others doesn't find value in it. Point is, what makes your heart beat faster might not be the same as everyone else ;) http://wordpress.com/notable-users/ <- there are quite a few very popular sites on that list. Could they maybe do the same without WP? Most likely. Would it cost them quite a bit more, and perhaps take longer to get everything working the same? Also quite likely.
     
    PoPSiCLe, Dec 25, 2013 IP
    ThePHPMaster likes this.
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #13
    Actually, are those popular sites? A lot of those look like blogs nobody actually visits attached to popular sites. Is CNN's website in WP? No, but the free blogs people can have are. Is that Reuters website that's in WP, or is it just user commentaries? They're all like that!

    For crappy little blogs nobody actually gives a **** about, WP is a cheap and easy solution. Doesn't make it good or even desirable for use as an actual website.

    In many ways it's a shame it's so ineptly coded; since it does have potential... if one were to clean up the endless pointless multiple entry (and therein attack) vectors, stop putting security info and database connections into the global scope, drag the markup kicking and screaming out of the "I can haz intarnets" garbage, etc, etc.

    But at that point, you'd probably put in less effort just starting over from scratch.
     
    deathshadow, Dec 25, 2013 IP
  14. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #14
    Fine - most of those are probably blogs - it be either user-blogs or corporate ones - but since there are quite a few quite successfull blogs running on WP, with maybe not millions, but at least a few hundred thousand visits, I still would say that among the blogosphere, at least, WP is the least bad. There are plenty of other permutations of CMSes out there, probably also quite a few which aren't natively English, which can do the same, but again, it's pretty much the same problem/advantage as most other popular softwaresolutions - there are plenty of tutorials, it's not too hard to get to grips with, and it doesn't cost much. Which are all pretty important for beginners/low-budget solutions.
     
    PoPSiCLe, Dec 26, 2013 IP
  15. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #15
    I actually agree with that -- but frankly that's a LOT of what's wrong with the web right now.
     
    deathshadow, Dec 27, 2013 IP