FW: [PHP-WIN] FW: Which function?
| From: | Gustav Wiberg | Date: | Thu, 30 Aug 2007 09:15:00 +0000 |
| Subject: | FW: [PHP-WIN] FW: Which function? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-28415@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Gustav Wiberg [mailto:gustav@hmn.se]
Sent: Thursday, August 30, 2007 11:15 AM
To: 'nadim@alienworkers.com'
Subject: RE: [PHP-WIN] FW: Which function?
Hi!
I got it working anyhow (just before you sent your answer- thanx by the way!)
The problem was that there was a text in the database that wasn't "together" and
It was like
Abc...abc...abcd<br>
Abc...abc...abcd
Instead of
Abc...abc...abcd<br>Abc...abc...abcd
And this I solved in the db (because in normal cases this "split of text" wouldn't
occur.
Best regards
/Gustav Wiberg
-----Original Message-----
From: Nadim Attari [mailto:nadim@alienworkers.com]
Sent: Thursday, August 30, 2007 11:09 AM
To: Gustav Wiberg
Subject: Re: [PHP-WIN] FW: Which function?
Gustav Wiberg wrote:
> Some more info:
>
> I get this (Javascript) error from Firebug:
>
> unterminated string literal
> Tip('\n
>
>
> Is this something that could be solved in php?
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Gustav Wiberg [mailto:gustav@hmn.se]
> Sent: Thursday, August 30, 2007 10:25 AM
> To: 'php-windows@lists.php.net'
> Subject: Which function?
>
> Hi there!
>
> Is there ant predefined function for doing this?
>
> I want to put text (from a database) inside quotes, like for example
> Javascript:window.alert('<?php echo $dbText;?>');
>
> Is there any function in PHP for translating $dbText into something that Javascript would
> accept? (something inside quotes)
> I tried with � ÙBÕÖŽÁ
> mWÎ `@http://se.php.net/manual/sv/function.htmlentities.php but that didn't
> seem to work
>
> Best regards
> /Gustav Wiberg
Hello,
Try to use this function to display your texts in JS
function txtForJS($text = '')
{
$txtForJS = '';
$text = trim($text);
if ($text != '')
{
for ($x = 0; $x < strlen($text); $x++) $textArr[$x] =
ord($text{$x});
$txtForJS = 'String.fromCharCode('.implode(',',
$textArr).')';
}
return $txtForJS;
}
Javascript:window.alert('<?php echo txtForJS($dbText); ?>');
Let me know if it worked.
Thx,
Nadim Attari
Alienworkers.com
Mauritius
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.12/979 - Release Date: 2007-08-29 20:21
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.484 / Virus Database: 269.12.12/979 - Release Date: 2007-08-29 20:21