Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mediumblob and html file

Posted on 2004-10-15
16
Medium Priority
?
394 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
  • 6
  • 5
  • 2
  • +2
16 Comments
 
LVL 13

Assisted Solution

by:cLFlaVA
cLFlaVA earned 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1700 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses

963 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