Solved

mediumblob and html file

Posted on 2004-10-15
16
363 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:Richard Coffre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +2
16 Comments
 
LVL 13

Assisted Solution

by:cLFlaVA
cLFlaVA earned 75 total points
ID: 12319139
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
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12319476
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 12319555
you might have use stripslashes so try

 echo stripslashes($invoice);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:NubKnacker2k
ID: 12319778
Check is your database connections and queries are working fine.

If possible, could you post the entire result?
0
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12320086
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
 
LVL 2

Expert Comment

by:ThePCNerd
ID: 12323867
1. Is there anything printing before this code?
2. Can we see the mediumblob text straight from the database without php?
0
 
LVL 2

Expert Comment

by:NubKnacker2k
ID: 12326865
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
 
LVL 2

Expert Comment

by:ThePCNerd
ID: 12328503
I would have asked that but I thought he wouldnt want to post all his code :/
0
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12336479
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 12337399
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
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12337909
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 12339526
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 12339537
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
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12345195
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
 
LVL 27

Accepted Solution

by:
Diablo84 earned 425 total points
ID: 12345687
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
 
LVL 1

Author Comment

by:Richard Coffre
ID: 12355352
So far I don't know because i use a function written by somebody else. But i'll find it out.

Regards
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

740 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