Alt tags in php

Posted on 2011-04-27
Last Modified: 2013-12-12
We are trying to get php/mysql to generate an alt tage from the content of the caption.

Two issues appear to be happening.

1) The caption has quote marks in it, so the alt text appears when mousing over the photo, but stops where the quote opens.

2) With this happening, the formatting for where the caption is supposed to be is not retained
ie, it is not showing in a table row and it is not showing in the proper font. The work when the alt tag is not there.
<img border="0" src="<?echo $main_articles['image'];?> "align="left" hspace="0" alt="<?echo stripslashes($main_articles['image_caption']);?>"/> </td>
                                          <td><font face="Verdana" size="1"><?echo stripslashes($main_articles['image_caption']);?><br>
                                                <?echo stripslashes($main_articles['image_credit']);?></font></td>

Open in new window

Question by:cuttone
    LVL 19

    Accepted Solution

    htmlentities ()
    alt="<?echo htmlentities (stripslashes($main_articles['image_caption']));?>"/>

    Open in new window


    Author Comment

    That was quick, and it worked. Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now