Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2

    Php alt tag in images dont work


    Hello.
    I use some components to instal games, flash games, and on web site their is a pictures of each games. But on pictures missing alt, and tittle tags. :S Tittle are not writed, but if know hav to insert tittle like alt tag, it would be great.
    Hier is code for this:
    PHP Code:
    <?php
        
    ///////////////////////////////////////
        // DROPDOWN ORDER END
        ///////////////////////////////////////

        ///////////////////////////////////////
        // GAMES BOXES START
        ///////////////////////////////////////
      
    $db =& JFactory::getDBO();

      for(
    $i=0;$i<count($this->games);$i++) {
        
    $game=$this->games[$i];
        
    $slug=$game->slug;

        
    $game->imgname=$this->params->get('dir_swf').$slug.'/'.$game->imgname;
        
    $game->description=$db->getEscaped($game->description);
        
    $game->description=str_replace("\\\"","\'",$game->description);
        
    $game->namett=$db->getEscaped($game->name);

       
    ?>


      <div class="game" style="text-align:center;">

        <a style="border:0;" href="<?php echo JRoute::_('index.php?option=com_yoflash&view=game&id='.$slug.'&Itemid='.$this->Itemid); ?>" onmouseover="Tip('<strong><?php echo $game->namett?></strong><br/> <?php echo $game->description?>',WIDTH,300,FADEIN,0,DELAY,0,BGCOLOR, '<?php echo $this->params->get('ttip_bgcolor'); ?>', BORDERCOLOR,'<?php echo $this->params->get('ttip_bordercolor'); ?>',FONTCOLOR,'<?php echo $this->params->get('ttip_fontcolor'); ?>',FONTSIZE,'<?php echo $this->params->get('ttip_fontsize'); ?>',FONTFACE,'<?php echo $this->params->get('ttip_fontface'); ?>')" onmouseout="UnTip()">

         <img src="<?php echo $game->imgname?>" width="100" height="100" alt="<?php echo $game->name?>"/><br/>
         <?php echo $game->name?>
        </a>

    </div>


       <?php
      
    }
    And this i get:
    Code:
    <a onmouseout="UnTip()" onmouseover="Tip('<strong>Alaska Jigsaw</strong><br/> Alaska Jigsaw are puzzle game in which you use the mouse to piece together few pictures of Alaska.',WIDTH,300,FADEIN,0,DELAY,0,BGCOLOR, '#E2E7FF', BORDERCOLOR,'#003099',FONTCOLOR,'#000044',FONTSIZE,'8pt',FONTFACE,'Verdana,Geneva,sans-serif')" href="/alaska-jigsaw.html" style="border:0;"><img width="100" height="100" alt="" src="/images/games/alaska-jigsaw/alaskajigsaw.jpg"></img><br></br>
          
         Alaska Jigsaw    
        </a></div>
    As i can see all work, except this with alt tag,
    this code
    PHP Code:
    alt="<?php echo $game->name?>"
    give
    Code:
    alt=""
    and this
    PHP Code:
    <?php echo $game->name?>
    give name of games. Which i whant to be in alt tags too, but on this part dont work. :S Please help.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    Why not just use $game->namett? That seems to be working.

    Also, your style is wrong. That's not how you do CSS styles at all.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    This is not my php code, i use from one components for adding games.
    I tray to add $game->namett but then i dont name of games, i get images name. :S Which look somethin like this games_112921'12 and like this.I dont know haw code write name on the last sections great, and in alt="" same code do not work. :S What is this?
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    PHP Code:
        $game->namett=$db->getEscaped($game->name); 
    That's how game->namett gets set. If you're saying it's an image name, you have more problems than i can fix with just this small snippet.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    This should put name of games inside the alt tags in images, but it puts image names. :S Which sometimes look strange, and not seo friendly. I dont understand whay this code
    PHP Code:
    <?php echo $game->name?>
    put game name, when are out from "", and inside alt="" dont write nothing. Did "" means somthing in php?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    Originally Posted by animation
    a speaking navigation plugin for for Joomla! 1.5 allowing you to insert additional text to your menu items. Features list Nonspeaking you can set several parameters: * Tag: Choose which HTML tag is used to display text. Default.
    What? I do not use Joomla 1.5, and what this have with no alt tag showing? I dont whant to insert aditional text in menu items, i whant to know whay code for showing some text do not work as it work on rest part.
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    You're talking to a spam bot. See the red "Warnings Level" and "Number of bans" in the top right corner? That's an indicator for spam.

    Apart from that, this all doesn't make sense. So $game->name is something like "Alaska Jigsaw", but $db->getEscaped($game->name) suddenly returns the name of the image in the form "games_112921'12"??

    Either you're totally mixing up the values, or your code is really, really broken. A database escaping function that magically turns names into file names doesn't work quite ... correctly.

    I suggest two things:
    • Fix your code. Instead of having all kinds of unescaped and escaped values (which overwrite the unescaped attributes), leave the attributes as they are and escape them right before you echo them.
    • Make a var_dump() for each relevant value to check the content.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    Originally Posted by Jacques1
    You're talking to a spam bot. See the red "Warnings Level" and "Number of bans" in the top right corner? That's an indicator for spam.

    Apart from that, this all doesn't make sense. So $game->name is something like "Alaska Jigsaw", but $db->getEscaped($game->name) suddenly returns the name of the image in the form "games_112921'12"??

    Either you're totally mixing up the values, or your code is really, really broken. A database escaping function that magically turns names into file names doesn't work quite ... correctly.

    I suggest two things:
    • Fix your code. Instead of having all kinds of unescaped and escaped values (which overwrite the unescaped attributes), leave the attributes as they are and escape them right before you echo them.
    • Make a var_dump() for each relevant value to check the content.
    First this is not my code, i use from another, and cand make sense in this, onlie little. But problem are that function
    PHP Code:
    <?php echo $game->name?>
    write game names, which are ok, but in this part of code
    PHP Code:
    <img src="<?php echo $game->imgname?>" width="100" height="100" alt="<?php echo $game->name?>"/><br/>
         <?php echo $game->name?>
    echo part for the name inside alt="" dont show anything. :S Whay this hapen? In one part show ok, in another part do not swow anything. :S
  16. #9
  17. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    I understand your problem, you explained it already.

    You have two options: You can keep wondering why this strange behaviour occurs and wait for somebody to come up with the magical explanation -- which will probably never happen. Or you can start investigating the problem.

    Like I said, make a var_dump() of $game->name before the HTML stuff. What does the attribute contain? Also try replacing the alt="echo ..." with some hard coded string (echo 'Test' or something like that).

    You know, try out different things. That's exactly what we do. We don't have any "magical powers" to find your bugs or something.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    Can you write exact what i need to do?
    Steps by steps. :S My php knowladge are very little. :/
  20. #11
  21. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    You know the var_dump function, right? I'm saying that you should use it to check the content of your variables. Like this, for example:
    PHP Code:
    var_dump($game->name); 
    This will tell you the exact content of the name attribute, so that we no longer have to speculate about it.

    Do that and post the exact output here:
    PHP Code:
    echo 'Testing: name, namett:<br>';
    var_dump($game->name);
    var_dump($game->namett);
    echo 
    'end of Testing.<br>'
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    string 'MINIBOT XP' (length=10)

    Testing: name, namett:

    string 'MINIBOT XP' (length=10)

    string 'MINIBOT XP' (length=10)

    end of Testing.
  24. #13
  25. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Thanks.

    But this clearly shows that namett is not an image name as you claimed earlier. So obviously you're confusing the different variables and attributes. Use namett in the alt attribute, because that's actually the correct (escaped) value.

    If it still doesn't work, echo a constant string in the alt attribute:
    PHP Code:
    alt="<?php echo 'foobar'?>"
    Does that work?
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    Originally Posted by Jacques1
    Thanks.

    But this clearly shows that namett is not an image name as you claimed earlier. So obviously you're confusing the different variables and attributes. Use namett in the alt attribute, because that's actually the correct (escaped) value.

    If it still doesn't work, echo a constant string in the alt attribute:
    PHP Code:
    alt="<?php echo 'foobar'?>"
    Does that work?
    I do not say namett are variables of images name. :S But in alt tag variables namett give name of images, not of game. :S So somthing must be wrong with sytax or something, i tray to find on web, but their in alt tag use another sintax. :S
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    65
    Rep Power
    2
    Ovo s foobarom ne radi.
    Probao sam to staviti, copy paste. Ne izbacuje mi ništa.Ali kada kopiram izvan img polja, ispiše mi foobar. Znaći mora biti neka zeka s img tagom. :S
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo