Too easy?

This is a discussion on Too easy? within the PHP General forums, part of the PHP Programming Forums category; Hello NG! Please have a look at the following lines of code: <html> <head> <script&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2007
age85@gmx.de
 
Posts: n/a
Default Too easy?

Hello NG!

Please have a look at the following lines of code:


<html>
<head>
<script>
function show(what) {
alert(what);
}
</script>
</head>
<body>
<?php
$name="Hello 'World'";
echo '<a href="javascript:show(\''.$name.'\')">Test</a>';
?>
</body>
</html>


The question is: how to safely quote the variable name? Via a build in
php or js function?
Please note that I know simple write $name="Hello \'World\'"; will
solve the problem, but thats not the point here.

Thanks in advance

René
René

Reply With Quote
  #2 (permalink)  
Old 11-01-2007
Vijay Joshi
 
Posts: n/a
Default Re: Too easy?

On Oct 31, 8:57 pm, ag...@gmx.de wrote:
> Hello NG!
>
> Please have a look at the following lines of code:
>
> <html>
> <head>
> <script>
> function show(what) {
> alert(what);}
>
> </script>
> </head>
> <body>
> <?php
> $name="Hello 'World'";
> echo '<a href="javascript:show(\''.$name.'\')">Test</a>';
> ?>
> </body>
> </html>
>
> The question is: how to safely quote the variable name? Via a build in
> php or js function?
> Please note that I know simple write $name="Hello \'World\'"; will
> solve the problem, but thats not the point here.
>
> Thanks in advance
>
> René
> René




here is it


<?php
$name="Hello 'World'";
echo '<a href="javascript:show(\''.addslashes($name).'\')"> Test</a>';
?>


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:07 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0