[FX.php List] Text encoding problem

Erik Andreas Cayré erik at cayre.dk
Sun Oct 15 13:23:17 MDT 2006


Den 15/10/2006 kl. 17.05 skrev Bob Patin:

> It's a fairly simple form; here's the code for editing the record:
>
> <?php
> include_once('FX/server_data.php');
> include_once('FX/FX.php');
>
> $title = $_POST['title'];
> $teaser = $_POST['teaser'];
> $newsitem = nl2br(stripslashes($_POST['newsitem']));

This is the culprit.
nl2br: You are converting newlines to <br> before storing into the db  
(which is what you don't want... right?)

Instead you may want the opposite...
Doing this conversion, when showing the contents of the db as HTML.  
(but not inside a TEXTAREA)...

> $id = $_POST['id'];
>
> $itin=new FX($serverIP,$webCompanionPort);
> $itin->SetDBData($dbname,'news');
> $itin->SetDBPassword('<pw>','<username>');
> $itin->AddDBParam('-recid',$id);
> $itin->AddDBParam('title',$title);
> $itin->AddDBParam('teaser',$teaser);
> $itin->AddDBParam('newsitem',$newsitem);
> $itinResult=$itin->FMEdit();
> include_once('news.php');
> ?>
>
> As you can see, I tried to strip out anything that might cause  
> trouble, in the line where $newsitem is retrieved from the POST form.
>

hope this helps

---
Erik Andreas Cayré
Spangsbjerg Møllevej 169
DK-6705 Esbjerg Ø

Home Tel: +45 75150512
Mobile: +45 40161183

»If you can't explain it simply, you don't understand it well enough.«
-- Albert Einstein

»If you don't have time to do it right, when will you have time to do  
it over?«
-- John Wooden, basketball coach


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1856 bytes
Desc: not available
Url : http://www.iviking.org/pipermail/fx.php_list/attachments/20061015/7b825daf/smime.bin


More information about the FX.php_List mailing list