Richard Coffre
asked on
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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you might have use stripslashes so try
echo stripslashes($invoice);
echo stripslashes($invoice);
Check is your database connections and queries are working fine.
If possible, could you post the entire result?
If possible, could you post the entire result?
ASKER
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>Information s 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@ansn atura.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.c om">444444 444@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</fon t></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</fo nt> </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:</f ont></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></t d> </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>
<!-- 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>Information
1. Is there anything printing before this code?
2. Can we see the mediumblob text straight from the database without php?
2. Can we see the mediumblob text straight from the database without php?
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?
This really looks like a problem with an open ". Can you post the code as well?
I would have asked that but I thought he wouldnt want to post all his code :/
ASKER
Hi,
Hereafter the complete code.
TIA
<?
$orderNumber = $_GET['fact'];
include("login.php");
include("bdd.inc.php");
$connect = @mysql_connect($serveur,$l ogin,$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";
}
?>
Hereafter the complete code.
TIA
<?
$orderNumber = $_GET['fact'];
include("login.php");
include("bdd.inc.php");
$connect = @mysql_connect($serveur,$l
@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";
}
?>
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,"In voice");
That will doubtfully fix your problem though, you can try
$invoice = mysql_result($result,0,"In voice");
echo stripslashes($invoice);
But as the html seems to be outputed correctly its difficult to pinpoint the problem.
while (list($invoice) = mysql_fetch_row($result))
{
echo "$invoice";
}
is pretty pointless, may as well just use:
echo mysql_result($result,0,"In
That will doubtfully fix your problem though, you can try
$invoice = mysql_result($result,0,"In
echo stripslashes($invoice);
But as the html seems to be outputed correctly its difficult to pinpoint the problem.
ASKER
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
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
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;
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;
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
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
in the head section of the tags
ASKER
Hi Diablo84,
I find that when I read the source code of the page, HTML entities are coded like this "<" = < so i use html_entity_decode to interpret correctly the code.
I find that when I read the source code of the page, HTML entities are coded like this "<" = < so i use html_entity_decode to interpret correctly the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So far I don't know because i use a function written by somebody else. But i'll find it out.
Regards
Regards
ASKER
<!-- 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>