PDA

View Full Version : Laszlo cant load thml tag in database


hokage
07-01-2008, 08:44 AM
i have some problem..it's make me curious...

i want to try to connect OL with MySql Through PHP..

here is the laszlo code

<canvas width="100%" height="100%">
<dataset name="dset" src="http://localhost/lightforum/lihatberita.php" request="true" type="http"/>
<simplelayout axis="y"/>


<view x="200" name="myTable">
<simplelayout axis="y"/>
<view name="rowOfData" datapath="dset:/phonebook/contact">
<simplelayout axis="x"/>
<text datapath="@title"/>
<text datapath="@message"/>
<text datapath="@postDate"/>
</view>
</view>
</canvas>
.

and here is php code for lihatberita.php

<?php

require_once('db_config.inc.php'); // connect mysql db through $dbh

$query = "SELECT * FROM berita";
$result = mysql_query($query,$dbh);

$_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .= "<phonebook>\r\n";

while ($row = mysql_fetch_array($result)) {
$_xml .= "\t<contact title=\"" . $row['title'] . "\" message=\"" . $row['message'] . "\" postDate=\"" . $row['postDate'] . "\" />\r\n";
}

$_xml .= "</phonebook>\r\n";

echo $_xml;

mysql_free_result($result);
mysql_close($dbh) or die ("Could not close connection to database!");

?>


it work, i see the database in mysql.. but somehow, message that have html tag cant be shown. i wonder why ?

please help me...

kampfkolosso
07-02-2008, 09:54 PM
Hi Hokage!

ok, i think this has something to do with you putting your db-data into the arguments of your contact-xml-object.
#1. pls encode everything in UTF-8, otherwise your xml is corrupted or you get some crumply characters
#2. consider putting everything that can contain characters other than the usual 26 english characters + numbers into the content of an xml-object.

e.g.:

<contact ...>
<message>my message where something is <b>bold</b></message>
</contact>

hence you can access the childnodes of the message-object and echo them as a string and you got your html-code...

hope that helps & have fun!

hokage
07-02-2008, 10:08 PM
ok thx..

i will try it...yeaaah...

hokage
07-04-2008, 07:51 AM
kampfkolosso i'm already try it...it's still not working...

my database already utf-8 ... and when i try

<contents>i want this to be <b>working<b></contents>

i'ts now shown anything...

kampfkolosso
07-04-2008, 08:14 AM
Huh, not exactly sure, but maybe a CDATA wrapper helps to preserve the tags.

<contect><![CDATA[this is html <b>content</b>]]></content>

How do you populate your textfield were you display the content?

hokage
07-10-2008, 03:03 AM
How do you populate your textfield were you display the content?

it work..in php files i added some code


$title = trim($_GET['title']);
$message = trim($_GET['message']);

$title = str_replace("<", "&lt;", $title);
$title = str_replace(">", "&gt;", $title);

$message = str_replace("<", "&lt;", $message );
$message = str_replace(">", "&gt;", $message );



to change < with &lt; and > with &gt

and also change " with ' ...