How to use html Tags from MySQL with PHP

I like HTML tags like <b>bold</b> or <BR>
and others placed in the MySQL database and used by PHP to show up
in my pages but I don't succeed. I tryied HTML encode
(htmlentities) from the bindings POP-up menu but nothing happened.
What is the way this should be acomplished and where is HTML
encode (and the others in the pop-up menu) being used for?
Any help will be appreciated,
Jos

arnhemcs wrote:
> I like HTML tags like
bold or <BR> and others placed in the MySQL
> database and used by PHP to show up in my pages but I
don't succeed. I tryied
> HTML encode (htmlentities) from the bindings POP-up menu
but nothing happened.
Just store the HTML as plain text in your database. Using
htmlentities()
turns < into &lt; and so on. Using it is what's
preventing your HTML
from displaying correctly.
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Similar Messages

  • How to use HTML Tags in webdynpro java

    Hi,
         Can any body tell me how to use HTML Tags in webdynpro java.
    If u provide me with sample code it will become more usefull.
    Thanks & Regards,
    SN

    HI,
    Please find the steps:
    Create a html file and store in your webdynpro project
    Add the html contents in your file
    & Create a IFRAME UI element and refer you html file
    Now you able to see the html in webdynpro
    Thanks & Regards,
    Ram

  • How to aviod html tags from Report column heading while export to csv

    Hi All,
    How to aviod html tags from Report column heading while export to excel.
    We used like Employee<br> Department in column heading, but the problem is the <br> tag also exporting into csv file.
    If any column data 3/2009 formatt the it will exporting as marh 2009.
    Please help on this.
    Thanks,
    Nr
    Edited by: pnr on Jul 5, 2011 5:00 AM

    Hi Nr
    Here is how I approached this problem.
    Go to report attributes tab
    under column attributes check PLSQL radio button.
    Create a function to return the heading of your report as shown below in your database.
    create function get_heading return clob as
    v_request VARCHAR2(20) := V('REQUEST');
    v_col_heading CLOB;
    begin
    IF INSTR(v_request,'FLOW_EXCEL_OUTPUT',1) > 0 THEN
    v_col_heading := 'Employee Number:Employee Name';
    ELSE
    v_col_heading := 'Employee breaktag Number:Employee break tag Name';
    END IF;
    return v_col_heading;
    end;
    Type the function below under ( Function returning colon delimited headings:) as follows.
    return get_heading;
    Similarly for data base it on PLSQL function body returning SQL and follow the same approach as headings.
    Hope this helps.
    Thanks
    Sukarna
    Edited by: user513776 on Jul 5, 2011 2:24 PM
    Edited by: user513776 on Jul 5, 2011 2:27 PM

  • How to use HTML Tags in Smartforms

    Hi,
    Can you please help me out in knowing how to use HTML tags in Smartforms,
    suppose i want to display some text in BOLD i should use the tag </b> as shown
    </b>  Header Information <b>
    regards
    Ranveer

    Hi Ranveer ,
        check this following links,
      hope this wil helps you
    <a href="http://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/smartforms/smartform%20in%20abap.pdf">check this link,to know abt HTML in smartforms</a>
    rgds,
    shan

  • How to use html tags inside java

    I have to retrieve data from db and return the data to my index.jsp page.
    Its working fine.
    But I have o display in a pable format using html. How to embed html tags? I tried this way. Its not working. Any suggestions?
       String htmlOpen = "<html>";
        String htmlEnd = "</html>";
        String titleOpen ="<title>";
        String titleEnd ="</title>";
        String bodyOpen = "<body>";
        String bodyEnd = "</body>";
        for (int i = 1; i <= cols;i++){
            output = output + rsmd.getColumnName(i);
         while (rst.next()) {
            for (int i = 1; i <= cols;i++){
                      output = output +rst.getString(i);
      result = htmlOpen + titleOpen + titleEnd + bodyOpen + output+ bodyEnd + htmlEnd;
        stmt.close();
        conn.close();
         return htmlOpen;
      }

    See those charcters in your JSP that look like "<%"? Those characters mean: "the code after this is Java - interpret it as such".
    Then when you close your Java block with "%>", it then means: "the code after this is html - output it to the request response that is being built. However, within the html code, the syntax "<%= java_variable_name %>" means "take the current value of that Java variable and insert it into the html output".
    Here's an example:
    %>
    <table cellspacing="2" cellpadding="2" border="1">
    <tr>
    <%
        String s = null;
        for (int i = 1; i <= ncol; i++)
          s = rsmd.getColumnName(i);
    %>
      <th nowrap><A HREF="<%=sortLink.toString()%>&sortby=<%=s%>"><%= s %></th>
    <%
    %>
    </tr>
    <%
        if (rs == null || numRows <= 0)
          %><tr><td colspan="10" nowrap>No data available for specified query.</td></td><%
        else
          int rowCounter = 0;
          while(rs.next() && rowCounter < PAGE_SIZE)
            rowCounter++;
    %>
      <tr><%
            for (int i = 1; i <= ncol; i++)
              s = rs.getString(i);
              if (rsmd.getColumnName(i).equalsIgnoreCase("password"))
                    %><td nowrap>********</td>
    <%
              else
                %><td nowrap><%= s %></td>
    <%
            %></tr><%
    %>
    </table>This is JSP 101, what they teach in the first hour of class...
    Here's a decent JSP tutorial:
    http://www.jsptut.com/

  • How to remove HTML tags from a String ?

    Hello,
    How can I remove all HTML Tags from a String ?
    Would you please to give me a simple example ?
    Best regards,
    Eric

    Here's some code I cooked up. I have created an object that processes code so that it can be incorporated directly into a project. There is some redundancy so that the it can be used in more than one way. Depending on your situation you might have to make the condition statement a little more sophisticated to catch stray ">" tags.
    I have also included a Tester application.
    //This removes Html tags from a String either by submitting the String during construction and then
    // calling getProcessedString() or
    // by simply calling " stringwithoutTags=removeHtmlTags(stringWithTagsSubmission); "
    //Note: This code assumes that all"<" tags are accompanied by a ">" tag in the proper order.
    public class HtmlTagRemover
         private String stringSubmission,processedString,stringBeingProcessed;
         private int indexOfTagStart,indexOfTagEnd;
         public HtmlTagRemover()
         public HtmlTagRemover(String s)
              removeHtmlTags(s);          
         public String removeHtmlTags(String s)
              stringSubmission=s;
              stringBeingProcessed=stringSubmission;
              removeNextTag();
              return processedString;
         private void removeNextTag()
              checkForNextTag();
              while((!(indexOfTagStart==-1||indexOfTagEnd==-1))&<indexOfTagEnd)
                   removeTag();
                   checkForNextTag();
              processedString=stringBeingProcessed;
         private void checkForNextTag()
              indexOfTagStart=stringBeingProcessed.indexOf("<");
              indexOfTagEnd=stringBeingProcessed.indexOf(">");
         private void removeTag()
              StringBuffer sb=new StringBuffer("");
              sb.append(stringBeingProcessed);
              sb.delete(indexOfTagStart,indexOfTagEnd+1);
              stringBeingProcessed=sb.toString();
         public String getProcessedString()
              return processedString;
         public String getLastStringSubmission()
              return stringSubmission;
    public class HtmlRemovalTester
         static void main(String[] args)
              String output;
              HtmlTagRemover h=new HtmlTagRemover();
              output="The processed String: "+h.removeHtmlTags("<Html tag>This is a test<another Html tag> string<yet another Html tag>.");
              output=output+"\n"+" The original string:"+h.getLastStringSubmission();
              System.out.print(output);

  • How to use HTML tags inside JSF pages

    I am creating a Menu using dataTable and outputLink in a JSF page.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
    <h:column>
    <li>
    <h:outputLink id="crumbID" value="#{bread.menuLink}">
    <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
    </h:outputLink>
    <li>
    </h:column>
    </h:dataTable>
    </ol>
    </div>
    </div>
    I want to use <li> HTML tag as shown in code above before and after every <tr> tag formed, but when i run it and see view source, this is how it shows:
    NOTE: you can see it has thrown out of <table> tag itself.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <li>
    </li>
    <table>
    <tbody>
    <tr>
    <td><a id="_id0:0:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=-1"><span id="_id0:0:crumpName" style="width: 165px;">Home</span></a></td>
    </tr>
    <tr>
    <td><a id="_id0:1:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=3~-1"><span id="_id0:1:crumpName" style="width: 165px;">HIM Admin</span></a></td>
    </tr>
    </tbody>
    </table>
    </ol>
    </div>
    </div>
    Can some one help me, how do i use HTML tags inside <h:dataTable>.
    Or is their any other way i should form my Menus, to fully utilize to HTML tags.
    Thanks
    Ravi

    Hello,
    You can embed the verbatim elements in your datatable, ie,
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
      <h:column>
        <f:verbatim><li></f:verbatim>
        <h:outputLink id="crumbID" value="#{bread.menuLink}">
          <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
        </h:outputLink>
        <f:verbatim></li></f:verbatim>
      </h:column>
    </h:dataTable>

  • How to exlcude HTML Tags from Excel Reports

    Hi Guys
    Within Project Online - OData extract to Excel
    Has anyone found a way to eliminate the HTML tags from Multi Line Text fields within Project Server? I can easily extract the text and generate nice Excel Reports, but the html tag is very annoying in the Excel Reports and it doesn't read easily.
    Any help would be appreciated.
    Marc Soester [MVP] http://marcsoester.blogspot.com

    Marc, 
    What you could do (given that you find the required time and energy to write the lines),
    would be to replace all (!) html characters like here (http://stackoverflow.com/questions/14705605/remove-html-tags-from-cell-strings-excel-formula -
    this is one of the Excel UDF/VB-based solutions, but will not refresh in Excel Services - however there is a good list of what to replace) with PowerQuery.
    That would refresh over a PowerBI subscription in the least..
    -Ville

  • How to remove html tags from a column

    Hi
    Problem is this: I get a column with a comma separated list of id's and I can successfully parse these id's and use them elsewhere. BUT, occasionally there are html tags within that id list like this:
    1082471,1237423<br xmlns="http://www.w3.org/1999/xhtml" />
    Is there a way to just automatically remove all tags from a column? Could do this with regex, but since there is no support, I don't know what to do.

    Hi,
    If the HTML can be detected by a starting symbol like „<“, then you could use the following:
    Unfortuntely the operation “ReplaceRange” is only available on a Text-level, so you have to invoke a function (at least to my knowledge). You also need an Index-column in your table, so if you don’t have it, you need to create one as well.
    This is your function:
    let
       fnRemoveHTML = (Value, Index) =>
    let
       Source = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content],
       IndeNo = Index,
       Value_ = Source{IndeNo-1}[Value],
       length = Text.Length(Text.From(Value_)),
       position = Text.PositionOf(Text.From(Value_), "<"),
       range = length-position,
       new= if Value_ is number then Value_ else Text.ReplaceRange(Value_, position, range, "")
    in
        new
    in
      fnRemoveHTML
    And this is how you invoke it:
    let
        Quelle = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content],
        Last = Table.AddColumn(Quelle, "Custom", each fn_RemoveHTML([Value], [Index])),
        ChangedType = Table.TransformColumnTypes(Last,{{"Custom", type number}})
    in
        ChangedType
    Provided your table is called “Tabelle1” & the column with your values to be replaced “Value” & your index-col “Index”
    Imke

  • How to remove html-tags from a text.

    Hello!
    I have a text-field which I will remove html-tag's from.
    Example:
    "This is a test<br><p> and another test"
    The function must return a similar text, but without the html-
    tags <br> and <p> (in this case).
    Anybody that can help me with this little problem?
    Thanks in advance for any help :-)
    Best regards
    Kjetil Klxve

    You can wait for some kind personal to post a complete code
    solution... But if you want to fix this yourself (which is good
    for the soul) here are some hints:
    - You can use SUBSTR to get at chunks of text
    - You can use INSTR to find particular characters.
    - You can use INSTR as an argument of SUBSTR
    Hence:
    bit_of_text := SUBSTR(text, 1, INSTR(text, '<'));
    chopped_text := SUBSTR(text, INSTR(text, '<'));
    bit_of_text := bit_of_text||SUBSTR(chopped_text, INSTR
    (text, '>'), INSTR(text, '<'));
    will give you the first bit of text that doesn't contain any
    angle brackets.
    From this you should be able to work out how to functionalised
    this (you'll need to store the offsets and use them in a loop
    construct).
    Note that this assumes that the text only contains the '<'
    character when it's part of a HTML tag. If you can't guarantee
    this then you'll have to explicitly search for all the tags e.g.
    bit_of_text := SUBSTR(text, 1, INSTR(lower(text), '<p>'));
    bit_of_text := SUBSTR(text, 1, INSTR(lower(text), '<br>'));
    This will be a bit of pain. And completely rules out XML!
    rgds APC

  • How to get html tags from JEditorPane ??

    Hi All,
    I have a html page that i am displaying in a JEditorPane with all support to styles and images as i have set content type of pane to text/html.
    When a user selects some text in JEditorPane, i want to get the content of the selected text, but not from text, but from HTML tags. In short what i want to know how can i get the html tags of the selected text in JEditorPane.
    Please tell me how to solve this problem.
    Thanks in advance
    Kind regards
    Chetan Chandarana

    thats very correct, but things is that the tags which i displayed are not getting retrived back from the textpane, specially some new line characters are coming.....any reason ?
    thanks for the reply
    kind regards
    Chetan Chandarana

  • How to remove html tags from the pdf file ?

    Hello,
    Using BI publisher we are generating a pdf file. In the table, we have data which contains html tags. for example " test1<br> 2.test2<br> 3.test3<br> ".
    In the pdf file we need to get the output like this
    test1
    test2
    test3
    But the output is as follows :"test1<br> 2.test<br> 3.test3<br> "
    Any idea, how these html tags can be removed from the pdf file and obtain the required result?
    Thanks in advance!!
    Archana

    Archana,
    Can you wrap your code in <code> tags (use square brackets rather than angled ones), as the forum software is interpretting the HTML tags, in other words we can't see what you mean ;)
    In any case, there are a few different options (guessing at what your problem is, without seeing the actual data), you could use htf.escape_sc or replace, regexp_replace etc to substitute the values before you output them to your PDF.
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Retrieving Images from Mysql with PHP

    Hi I have been trying to work this out with no success so some help would be really appreciated.
    I have two tables  in Mysql,
    IMAGES  AND EXHIBITORS
    IMAGES
    `image_id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT ,
      `filename` VARCHAR(255) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
      `mime_type` VARCHAR(255) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
      `file_size` INT(11) NOT NULL ,
      `file_data` LONGBLOB NOT NULL ,
      `user_id` VARCHAR(50) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
      `accom_id` INT(5) NOT NULL ,
      `exhibitors_exhib_id1` INT(5) NOT NULL ,
    PRIMARY KEY (`image_id`, `exhibitors_exhib_id1`) ,
    INDEX `user_id` (`user_id` ASC) ,
    INDEX `accom_id` (`accom_id` ASC) ,
    INDEX `fk_images_exhibitors2` (`exhibitors_exhib_id1` ASC) ,
    CONSTRAINT `fk_images_exhibitors2`
    FOREIGN KEY (`exhibitors_exhib_id1` )
    REFERENCES `christmas_shopping`.`exhibitors` (`exhib_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
    ENGINE = InnoDB
    AUTO_INCREMENT = 7
    DEFAULT CHARACTER SET = latin1
    COLLATE = latin1_bin
    EXHIBITORS
    `exhib_id` INT(5) NOT NULL AUTO_INCREMENT ,
      `exhib_name` VARCHAR(50) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
      `exhib_years` SET('2010', '2009') NULL ,
      PRIMARY KEY (`exhib_id`) )
    ENGINE = InnoDB
    AUTO_INCREMENT = 3
    DEFAULT CHARACTER SET = latin1
    COLLATE = latin1_bin
    PACK_KEYS = DEFAULT
    I think I am happy with the Mysql,  and I have read the various arguments about storing images in mysql but for my purpose I wanted to store the image in the database.
    I have already created the upload and the images have uploaded correctly and I can see the data in the database, however I just have been able to retrieve the images back into a webpage.
    I have a .php file which is merging these to tables correctly but the image is displayed as
    o¿9®&#143;áŸÇ½G_ŒÁ%×Úoíø&#157;$M©7ûiè Óµ|Mn.˨â=Ž&#127;2Z ¥<º½Hs/¸úfŠÇðïˆ-üE`· &#157;¯üq÷C[ öTªÂ´ Jnéžl¢âÜdµ (¢µ$(¢Š�(¢Š�(¢Š�(¢Š�(¢Š�(¢Š�CÅ Š:šZ�(¢Š�(¢Š�) -!  ¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¯ ý¤Z_ x^óÃ&#144;K2ZJ»¦ò>ô»NJ ûç¥{6½©.‘£ÝÞ &#144;ÆZ¼*-Sûz"$pÌ]&#157;$þ%5ù¿ æ•0˜xa©;9êý O›=¼³ ªÍÔžÈøžþ t·[c*¦À  T?wøQ·/?ίøWÅ×z]Ü  r츌þæLôoâVþð¯jøÍð¶O Y½Îœ¨Œ›–k4OšWþê·mß1÷/ Abž<[Þ¢þþÕŠþ÷ûÛ&#127;&#157;}nCžÏ*š¡]Þ“ü?¯ëÏ‹ …X¨óÇIþgÔÔVf‹¬Ûë¶)snÙVê½Á:ý¶ &#141;H©ÁÝ=&#143;–iÅÙî QEh   ¢Š(�¢Š(�¢Š(�¢Š(�¤4´‚€ Š(  Š(  Š(  Š(   qKHh Ð ÑE �QE �QE �QE �V^½ª¦‡¥^²ï .í¾µ©^kñÿ�Z  Ã]NmÛY“
    The code I have in the page is as follows. After many hours of trying to work it out I just cant see what I am missing and would really appreciate some help. I have highlighted where the echo is that relates to my image.
    <?php require_once('../Connections/christmas.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
      $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
    mysql_select_db($database_christmas, $christmas);
    $query_Recordset1 = "SELECT exhibitors.exhib_name, images.file_size, images.file_data FROM images, exhibitors WHERE images.exhib_id = exhibitors.exhib_id";
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $christmas) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    if (isset($_GET['totalRows_Recordset1'])) {
      $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
      $all_Recordset1 = mysql_query($query_Recordset1);
      $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php $pagetitle="The Christmas Shopping Fayre"?>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <meta http-equiv="Content-Type" content="; charset=" />
    <link href="../public/CSSFiles/oneColElsCtrHdr.css" rel="stylesheet" type="text/css" />
    <link href="../public/CSSFiles/whitebackground.css" rel="stylesheet" type="text/css"/>
    <link href="../public/CSSFiles/shoppingonline.css" rel="stylesheet" type="text/css"/>
    <link rel="icon" type="image/x-icon" href="http://www.gravatar.com/avatar/c4dac336c5be729fc542c12bfbb50099.png" />
    <!--[if IE]>
    <style type="text/css">
    a { zoom: 1;}
    </style>
    <![endif]-->
    <script type="text/javascript">
    <!--
    function MM_showHideLayers() { //v9.0
      var i,p,v,obj,args=MM_showHideLayers.arguments;
      for (i=0; i<(args.length-2); i+=3)
      with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
        obj.visibility=v; }
    //-->
    </script>
    </head>
    <body id="shoppingonline" class="oneColElsCtrHdr">
    <p> </p>
    <?php include("includes/header.php"); ?>
    <br />
    <br />
    <div id="bannersp"> </div>
    <h1>Welcome to <?php echo $pagetitle?></h1>
    <p>
    </p>
    <form method="post" name="form1" id="form1">
    <p> </p>
    <table border="1" cellpadding="5" cellspacing="5">
      <tr>
        <td>exhib_name</td>
        <td>file_size</td>
        <td>file_data</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_Recordset1['exhib_name']; ?></td>
          <td><?php echo $row_Recordset1['file_size']; ?></td>
          <td><?php echo $row_Recordset1['file_data']; ?></td>
        </tr>
        <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
    <?php include("includes/footer.php"); ?>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

    Hi Murray
    You must despair with beginers like me,  attachments showed as having been
    sent so lets try again.
    I have been able to find a tutorial  that works well all the way through, I
    can even see the images in the browser!!  but only shows images individually
    on a page.
    http://www.phpriot.com/articles/storing-images-in-mysql/7
    However, what I want to do is to have a page that links my images table and
    another table,  all of which I have set up and is working other then showing
    the images.  All was very straight forward until sorting out the image.  If
    I can work out what to take from the above tutorial that works into my page,
    I am sure all will be fab.
    Storing them in the mysql was my preferred method as there are not alot and
    they can be low resolution and I thought it would be fairly straight
    forward!!  however finding out that I am having to adapt code as dreamweaver
    doesn't support the blob attribute is getting me out of my knowledge.
    All the best
    Gilly
    Attachments inserted
    show_image.php
    <?php require_once('../Connections/getImage.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname_Recordset1 = "-1";
    if (isset($_GET['image_id'])) {
      $colname_Recordset1 = $_GET['image_id'];
    mysql_select_db($database_getImage, $getImage);
    $query_Recordset1 = sprintf("SELECT image_id, mime_type, file_data FROM images WHERE image_id = %s", GetSQLValueString($colname_Recordset1, "int"));
    $Recordset1 = mysql_query($query_Recordset1, $getImage) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    header('Content-type: ' . $row_getImage['mime_type']);
    echo $row_getImage['file_data'];
    mysql_free_result($Recordset1);
    ?>
    view.php
    <?php require_once('../Connections/getImage.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
      $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
    mysql_select_db($database_getImage, $getImage);
    $query_Recordset1 = "SELECT * FROM images";
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $getImage) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    if (isset($_GET['totalRows_Recordset1'])) {
      $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
      $all_Recordset1 = mysql_query($query_Recordset1);
      $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <table border="1" cellpadding="5" cellspacing="5">
      <tr>
        <td>image_id</td>
        <td>filename</td>
        <td>mime_type</td>
        <td>file_size</td>
        <td>file_data</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_Recordset1['image_id']; ?></td>
          <td><?php echo $row_Recordset1['filename']; ?></td>
          <td><?php echo $row_Recordset1['mime_type']; ?></td>
          <td><?php echo $row_Recordset1['file_size']; ?></td>
          <td><?php echo $row_Recordset1['file_data']; ?></td>
          <td><img src="show_image.php?image_id=<?php echo
    $row_getdetails['image_id']; ?>" alt="Image from DB" />
    </td>
        </tr>
        <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

  • I want to display BLOB image in JSP Using  html tags IMG src=

    GoodAfternoon Sir/Madom
    I Have got the image from oracle database but want to display BLOB image using <IMG src="" > Html tags in JSP page . If it is possible than please give some ideas or
    Send me sample codes for display image.
    This code is ok and working no problem here Please send me code How to display using html tag from oracle in JSP page.
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="javax.swing.ImageIcon;" %>
          <%
            out.print("hiiiiiii") ;
                // declare a connection by using Connection interface
                Connection connection = null;
                /* Create string of connection url within specified format with machine
                   name, port number and database name. Here machine name id localhost
                   and database name is student. */
                String connectionURL = "jdbc:oracle:thin:@localhost:1521:orcl";
                /*declare a resultSet that works as a table resulted by execute a specified
                   sql query. */
                ResultSet rs = null;
                // Declare statement.
                PreparedStatement psmnt = null;
                  // declare InputStream object to store binary stream of given image.
                   InputStream sImage;
                try {
                    // Load JDBC driver "com.mysql.jdbc.Driver"
                    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                        /* Create a connection by using getConnection() method that takes
                        parameters of string type connection url, user name and password to
                        connect to database. */
                    connection = DriverManager.getConnection(connectionURL, "scott", "root");
                        /* prepareStatement() is used for create statement object that is
                    used for sending sql statements to the specified database. */
                    psmnt = connection.prepareStatement("SELECT image FROM img WHERE id = ?");
                    psmnt.setString(1, "10");
                    rs = psmnt.executeQuery();
                    if(rs.next()) {
                          byte[] bytearray = new byte[1048576];
                          int size=0;
                          sImage = rs.getBinaryStream(1);
                        //response.reset();
                          response.setContentType("image/jpeg");
                          while((size=sImage.read(bytearray))!= -1 ){
                response.getOutputStream().write(bytearray,0,size);
                catch(Exception ex){
                        out.println("error :"+ex);
               finally {
                    // close all the connections.
                    rs.close();
                    psmnt.close();
                    connection.close();
         %>
         Thanks

    I have done exactly that in one of my applications.
    I have extracted the image from the database as a byte array, and displayed it using a servlet.
    Here is the method in the servlet which does the displaying:
    (since I'm writing one byte at a time, it's probably not terribly efficient but it works)
         private void sendImage(byte[] bytes, HttpServletRequest request, HttpServletResponse response) throws IOException {
              ServletOutputStream sout = response.getOutputStream();
              for(int n = 0; n < bytes.length; n++) {
                   sout.write(bytes[n]);
              sout.flush();
              sout.close();
         }Then in my JSP, I use this:
    <img src="/path-to-servlet/image.jpg"/>
    The name of the image to display is in the URL as well as the path to the servlet. The servlet will therefore need to extract the image name from the url and call the database.

  • How to fetch data from Mysql with SSL.

    I am using jdk1.5 and mysql 5.0.
    How to fetch data from Mysql with SSL
    I am using url = jdbc:mysql://localhost/database?useSSL=true&requireSSL=true.
    It shows error. how to fetch

    I have created certificate in mysql and checked in mysql.
    mysql>\s
    SSL: Cipher in use is DHE-RSA-AES256-SHA
    but through ssl how to fetch data in java.

Maybe you are looking for