mediumblob and html file

Hi all,

I'm working with a table where the invoice is in HTML format and stored in a mediumblob.
So when I retrieve the invoice and display it with the following code :

while (list($invoice) = mysql_fetch_row($result))
{
   echo "$invoice";
}

Previously it was correctly managed : display a formatted invoice.
Now it shows the HTML code and nothing more.

Any idea in order to make sure the display will be correct ?

TIA
LVL 1
Richard Coffree-commerce Product ManagerAsked:
Who is Participating?
 
Diablo84Commented:
Are you using the htmlentities function or the htmlspecialchars function when you insert or retrieve the data from the database, these will cause the conversion of <, >,",' etc so you do not need them. The entities should not be converted automatically.
0
 
cLFlaVACommented:
Does the code stored in the db look like this:

    <a>a link</a>

or like this:

   &lt;a&gt;a link&lt;/a&gt;


?
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
The code starts like this :
<!-- admin part of invoice_print start -->  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>
...

and stops like this :
</table> <!-- admin part of invoice_print end --> </body> </html>
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Diablo84Commented:
you might have use stripslashes so try

 echo stripslashes($invoice);
0
 
NubKnacker2kCommented:
Check is your database connections and queries are working fine.

If possible, could you post the entire result?
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
Hereafter the entire result :

<!-- admin part of invoice_print start --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ANS Natura</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <body> <table width="650" border="1" bordercolor="#333333" cellspacing="0"> <tr> <td colspan="5" align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif"><b>ANS Natura</b></font> <br> <font size="1" face="Arial, Helvetica, sans-serif">Date: 29-09-04 16:14</font> </td> </tr> <tr> <td colspan="2" align="center" valign="top"><font size="1" face="Arial, Helvetica, sans-serif"><u>Informations sur la boutique:</u></font></td> <td colspan="3" align="center" valign="top"><font size="1" face="Arial, Helvetica, sans-serif"><u>Données du client:</u></font></td> </tr> <tr> <td align="left" valign="top" width="25%"><font size="1" face="Arial, Helvetica, sans-serif">ANS Natura<br> Poste française<br> BP 287<br> Andorre la Vieille, <br> Andorra</font> </td> <td align="left" valign="top" width="25%"><font size="1" face="Arial, Helvetica, sans-serif">0000000000<br> 00 376 867 555<br> <a href="mailto:commande@ansnatura.com">commande@ansnatura.com</a><br> <a href="http://www.ansnatura.com" target="_blank">http://www.ansnatura.com</a></font> </td> <td align="left" valign="top" width="25%"><font size="1" face="Arial, Helvetica, sans-serif">4444444<br> 4444444<br> 4444444<br> 444444444, 4444444<br> Albania </font> </td> <td align="left" valign="top" width="25%"><font size="1" face="Arial, Helvetica, sans-serif"> 4444444<br> 44444444444<br> <a href="mailto:444444444@4.com">444444444@4.com</a></font> </td> </tr> <tr> <td height="14" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif"><u>Détails de livraison:</u></font> </td> <td colspan="4" rowspan="2" align="center" valign="top"> <table border="0"> <tr> <td align="left" valign="top"><font size="1" face="Arial, Helvetica, sans-serif">Vous avez choisi le mode de paiement: </font> </td> <td width="165" align="left" valign="top"><font size="1" face="Arial, Helvetica, sans-serif">Chèque ou mandat </font> </td> </tr> <tr> <td align="left" valign="top"><font size="1" face="Arial, Helvetica, sans-serif">Vous avez choisi le mode livraison:</font> </td> <td align="left" valign="top"><font size="1" face="Arial, Helvetica, sans-serif">Colis Express - Livraison sous 48 heures - Port offert à partir de 150 € d'achats.</font> </td> </tr> </table> </td> </tr> <tr> <td align="left" valign="top"><font size="1" face="Arial, Helvetica, sans-serif">4444444<br> 4444444<br> 4444444<br> 444444444, 4444444<br> Albania</font> </td> </tr> </table> <font size="2" face="Arial, Helvetica, sans-serif"><br> </font> <table width="650" border="1" cellspacing="0" bordercolor="#333333"> <tr> <td width="75" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Référence</font></td> <td align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Produit</font></td> <td width="75" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Quantité commandée</font></td> <td width="75" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Prix du produit</font></td> <td width="75" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">TVA</font></td> <td width="75" align="center" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Total</font></td> </tr> <tr> <td width="75"> <font size="1" face="Arial, Helvetica, sans-serif">AC27</font> </td> <td> <font size="1" face="Arial, Helvetica, sans-serif">ACEROLA VITAMINE C</font> </td> <td width="75" align="center" valign="middle"> <font size="1" face="Arial, Helvetica, sans-serif">2147483647</font> </td> <td width="75" align="center" valign="middle"> <font size="1" face="Arial, Helvetica, sans-serif">11,00 €</font> </td> <td width="75" align="right"> <font size="1" face="Arial, Helvetica, sans-serif">0,00 €</font> </td> <td width="75" align="right"> <!-- 722z correction (remplacer "ItemCostLong" par "ItemCostTotal") --> <font size="1" face="Arial, Helvetica, sans-serif">23 622 320 117,00 €</font> </td> </tr> </table> <table width="650" border="1" bordercolor="#333333" cellspacing="0"> <tr> <td align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Sous-total:</font></td> <td width="75" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">23 622 320 117,00 €</font></td> </tr> <tr> <td align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Frais de paiement: </font></td> <td width="75" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">0,00 €</font></td> </tr> <tr> <td align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Frais d'expédition: </font></td> <td width="75" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">0,00 €</font></td> </tr> <tr> <td> <table width="100%" border="0"> <tr> <td width="31%" align="left" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Numéro de TVA:</font></td> <td width="44%"><font size="1" face="Arial, Helvetica, sans-serif"></font></td> <td width="25%" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">TVA:</font></td> </tr> </table> </td> <td width="75" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">0,00 €</font></td> </tr> <tr> <td align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Total:</font> </td> <td width="75" align="right" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">23 622 320 117,00 €</font></td> </tr> </table> <br> <table width="650" border="1" cellspacing="0" bordercolor="#333333"> <tr> <td align="left" valign="middle"><font size="1" face="Arial, Helvetica, sans-serif">Lien vers la facture:<br> <a href="http://www.ansnatura.com/index.php?module=pncommerce&func=receipt&ON=80&KID=7ec469097c9ffa4782ba526bcde201d8" target="_blank">http://www.ansnatura.com/index.php?module=pncommerce&func=receipt&ON=80&KID=7ec469097c9ffa4782ba526bcde201d8</a></font></td> </tr> <tr> <td align="left" valign="middle"> <p><font size="1" face="Arial, Helvetica, sans-serif">Numéro de commande: 80</font></p> </td> </tr> <tr> <td><font size="1" face="Arial, Helvetica, sans-serif">Commentaires:<br> </font></td> </tr> <tr> <td align="center" valign="middle"><font size="2" face="Arial, Helvetica, sans-serif"><b> <br>Merci pour votre commande. <br>Cette commande a été automatiquement générée depuis le site Internet <br><br>Veuillez sauvegarder cette facture, vous pouvez l'imprimer pour votre comptabilité. <br><br></b></font></td> </tr> </table> <!-- admin part of invoice_print end --> </body> </html>
0
 
ThePCNerdCommented:
1. Is there anything printing before this code?
2. Can we see the mediumblob text straight from the database without php?
0
 
NubKnacker2kCommented:
From what I understand, the results are being pulled properly from the database but their display is messed. Right?

This really looks like a problem with an open ". Can you post the code as well?
0
 
ThePCNerdCommented:
I would have asked that but I thought he wouldnt want to post all his code :/
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
Hi,

Hereafter the complete code.

TIA

<?
$orderNumber = $_GET['fact'];

include("login.php");
include("bdd.inc.php");

$connect = @mysql_connect($serveur,$login,$pass);
@mysql_select_db($base);

$query  = "SELECT Invoice "; $query .= "FROM `nuke_pncommerce_invoices` ";
$query .= "WHERE OrderNumber = $orderNumber ";

$result = @mysql_query($query, $connect);
$errno = @mysql_errno($connect);
$error = @mysql_error($connect);

if ($errno != 0)
{
      echo "Operation failed : $errno - $error<br />\n";
}

while (list($invoice) = mysql_fetch_row($result))
{
   echo "$invoice";
}
 
?>
0
 
Diablo84Commented:
As your only dealing with one record from one row:

while (list($invoice) = mysql_fetch_row($result))
{
   echo "$invoice";
}

is pretty pointless, may as well just use:

echo mysql_result($result,0,"Invoice");

That will doubtfully fix your problem though, you can try

$invoice = mysql_result($result,0,"Invoice");
echo stripslashes($invoice);

But as the html seems to be outputed correctly its difficult to pinpoint the problem.
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
I copied the result in afile named invoice.html.
The browser processed it as a text file and not a HTML one. I'm under Windows and the table was filled under Linux.
So when I want to open the HTML file with Ultraedit, it asks me to convert or not the file.

Finally, it seems to be a problem of conversion between Unix format and Windows one and new line coding.

Any idea to solve it

TIA
0
 
Diablo84Commented:
1) to get the file recognised as a html file add the following line to the top of the page
header('Content-type: text/html');
It will of course have to be parsed by the php engine (.php extension)

2)

>> Finally, it seems to be a problem of conversion between Unix format and Windows one and new line coding.

Unix systems use \n for new lines, Windows uses \r\n so you could try

$var = ""; //your text
$var = str_replace("\r","",$var);
echo $var;
0
 
Diablo84Commented:
for 1) you might actually be able to get it to recongise the html by adding:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

in the head section of the tags
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
Hi Diablo84,

I find that when I read the source code of the page, HTML entities are coded like this "<" = &lt; so i use html_entity_decode to interpret correctly the code.
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
So far I don't know because i use a function written by somebody else. But i'll find it out.

Regards
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.

All Courses

From novice to tech pro — start learning today.