• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

Save HTML in MySQL

how I can save html in mySQL?  Using PHP

the HTML contain pictures and links


any Idea?
0
PLCITS
Asked:
PLCITS
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
the HTML contain pictures and links
Technically, no it doesn't.  HTML is all text with Links to pictures.  The pictures are not part of the HTML file and have to be loaded and saved separately.
0
 
Chris StanyonCommented:
As Dave's pointed out, HTML is just text:

<p>This is a <a href='somePage.php'>link</a></p>
<div><img src='someImage.png' alt='An Image of Something'></div>

If you want to save the HTML to you database, then it's fairly straight forward:

$sampleHtml = <<<EOT
<p>This is a <a href='somePage.php'>link</a></p>
<div><img src='someImage.png' alt='An Image of Something'></div>
EOT;

$dbh = new PDO("mysql:host=yourHost;dbname=yourDb", "yourUser", "yourPass");
$stmt = $dbh->prepare("INSERT INTO yourTable (HtmlColumn) VALUES (?)");
$stmt->execute( array($sampleHtml) );

Open in new window

If you need anything more specific, you''ll need to give us more details of what you need.
0
 
M. AhsanCommented:
$html = addslashes('<div id="intro">
<div id="about" align="left">
<h2 class="bigHeader" dir="rtl"HEADER</h2>
<img src="img/Med-logo.png" alt="" />
<div id="wellcomePage" class="text-left text" dir="rtl">
<p>...some words....</p>
<p>.some words....</p>
<p>&nbsp;</p>
</div>
</div>
</div>');

After this, form an SQL query.

$sql = "UPDATE `Pages` SET `content`= '".$html."'";
0
 
PLCITSAuthor Commented:
Hi Im Saving html from emails, with IMAP I got the html email and I want to save in mysql  Im using righ now urlencode but i dont know if that is the correct way

this is one example of HTML


<!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></title>
</head>
<body>
<table class='mailbox-read-message' border='0' cellpadding='0' cellspacing='0' width='90%' style='font-family:Tahoma, Geneva, sans-serif; font-size:12px;'>
<tr>
          <td>&nbsp;
          
        </td>
    </tr>
    <tr>
          <td>
              <table border='0' bgcolor='#EAEAEA' width='100%'>
                  <tr>
                      <td align='left' width='10%'>
                          <B>From:</B>
                    </td>
                    <td align='left' width='66%'>
                                     jorgz@plc.com                    </td>
                    <td width="24%">
                   
                          <b>Sent:</b> 20/11/2017 16:42 pm                    </td>
                </tr>
                     <tr>
                      <td>
                          <b>To:</b>
                    </td>
                    <td>
                    jose Lopez
                    </td>
                    <td>
                    </td>
                </tr>
                  <tr>
                      <td>
                          <b>CC:</b>
                    </td>
                    <td>
                                        </td>
                    <td>
                    </td>
                </tr>
                  <tr>
                      <td>
                          <b>Subject:</b>
                    </td>
                    <td>
                                    Attachment                    </td>
                    <td>
                    </td>
                </tr>                
                  <tr>
                      <td colspan='3'>
                          <table bgcolor='#FFFFFF'>
                              <tr>
                                  <td>
                                      Copy of Audit_Arizona-Florida-Michigan-Texas-Washington.xls
Joez.docx
2017_07_14_14_38_54.pdf
DHCP.jpg
RFIDTest.zip
                                </td>
                            </tr>
                              <tr>
                                  <td>
                                                      &nbsp;
                                </td>
                            </tr>
                              <tr>
                                  <td>
                                                      <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
      {font-family:Calibri;
      panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
      {font-family:Tahoma;
      panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
      {margin:0in;
      margin-bottom:.0001pt;
      font-size:11.0pt;
      font-family:"Calibri","sans-serif";
      mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
      {mso-style-priority:99;
      color:blue;
      text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
      {mso-style-priority:99;
      color:purple;
      text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
      {mso-style-priority:99;
      mso-style-link:"Balloon Text Char";
      margin:0in;
      margin-bottom:.0001pt;
      font-size:8.0pt;
      font-family:"Tahoma","sans-serif";
      mso-fareast-language:EN-US;}
span.EmailStyle17
      {mso-style-type:personal-compose;
      font-family:"Calibri","sans-serif";
      color:windowtext;}
span.BalloonTextChar
      {mso-style-name:"Balloon Text Char";
      mso-style-priority:99;
      mso-style-link:"Balloon Text";
      font-family:"Tahoma","sans-serif";}
.MsoChpDefault
      {mso-style-type:export-only;
      font-family:"Calibri","sans-serif";
      mso-fareast-language:EN-US;}
@page WordSection1
      {size:8.5in 11.0in;
      margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
      {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ES-MX" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height:16.5pt">
<td style="padding:0in 0in 0in 0in;height:16.5pt">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7D7D7D;mso-fareast-language:ES-MX">Joe omz</span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr style="height:16.5pt">
<td style="padding:0in 0in 0in 0in;height:16.5pt">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">Info Systems</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr style="height:16.5pt">
<td style="padding:0in 0in 0in 0in;height:16.5pt">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;mso-fareast-language:ES-MX"><a href="mailto:joe.omez@plc.com" title="Click to send email to joe omez"><span style="color:blue">joe.omez@plc.com</span></a></span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr style="height:16.5pt">
<td style="padding:0in 0in 0in 0in;height:16.5pt">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">Voice</span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
</span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">000.000.0000</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
<span style="color:#A5A5A5">|</span> </span></b><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">Fax</span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
</span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">000.000.0000</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr style="height:21.0pt">
<td style="padding:0in 0in 0in 0in;height:21.0pt">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">Plc</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
<span style="color:#A5A5A5">|</span> </span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">210 ustrial Pkwy</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
<span style="color:#A5A5A5">|</span> </span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">Santa</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">,</span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX">
</span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#A5A5A5;mso-fareast-language:ES-MX">CA</span><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;display:none;mso-fareast-language:ES-MX"><o:p>&nbsp;</o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<p class="MsoNormal" align="center" style="text-align:center"><a href="mailto:sales@plc.com?Subject=How%20can%20the%20SCP%20help%20me%20get%20results%20fast?&amp;body=Hello%20Primuslabs%20Sales%20team,%0D%0A%0D%0AI%20would%20like%20to%20know%20how%20my%20free%20SCP%20account%20works%20and%20how%20I%20can%20receive%20all%20of%20lab%20results%20in%20one%20place,%20organized,%20and%20connected%20with%20my%20buyers.%20Please%20contact%20me%20as%20soon%20as%20possible.%0D%0A%0D%0A%20Thank%20you," target="_top"><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:blue;mso-fareast-language:ES-MX;text-decoration:none"><img border="0" width="520" height="217" id="_x0000_i1027" src="cid:image001.png@01D3621E.88869A60" alt="FA"></span></b></a><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<p class="MsoNormal" align="center" style="text-align:center"><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><img border="0" width="520" height="157" id="_x0000_i1026" src="cid:image002.png@01D3621E.88869A60" alt="Thank you 30 Years"></span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
<tr>
<td valign="top" style="padding:0in 0in 0in 0in">
<p class="MsoNormal" align="center" style="text-align:center"><a href="mailto:fasupport@azl.com?Subject=I%20want%20to%20learn%20more%20about%20FA%20Support%20Services%20&amp;body=Hello%20FA%20Support%20Team,%0D%0A%0D%0AI%20want%20to%20learn%20about%20your%20FA%20Support%20Services.%20Please%20contact%20me%20as%20soon%20as%20possible.%0D%0A%0D%0AThank%20you," target="_top"><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:blue;mso-fareast-language:ES-MX;text-decoration:none"><img border="0" width="520" height="94" id="_x0000_i1025" src="cid:image003.png@01D3621E.88869A60" alt="FA Support"></span></b></a><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;display:none;mso-fareast-language:ES-MX"><o:p>&nbsp;</o:p></span></p>
<table class="MsoNormalTable" border="0" cellpadding="0">
<tbody>
<tr>
<td style="border:none;border-top:solid #A5A5A5 1.0pt;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#BFBFBF;mso-fareast-language:ES-MX">This email and any files transmitted with it may contain confidential information and is intended solely for use by the individual
 to whom it is addressed. If you received this email in error, please notify the sender, do not disclose its contents to others and delete from your system.
</span></b><b><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;mso-fareast-language:ES-MX"><o:p></o:p></span></b></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;display:none;mso-fareast-language:ES-MX"><o:p>&nbsp;</o:p></span></p>
<table class="MsoNormalTable" border="0" cellpadding="0">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt"></td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>                                                
             </table>
        </td>
    </tr>
      <tr>
    </tr>    
</table>
</body>
</html>
0
 
Chris StanyonCommented:
Not sure what you mean by using the URL Encode.

I've shown you the code to save your HTML into a database using PHP. How are you planning on getting the HTML from the email into your PHP script ??
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now