Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5357

Re: variable path lose slashs when used in an alert

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: variable path lose slashs when used in an alert
Date Fri, 06 Apr 2012 17:37:09 +0200
Lines 32
Message-ID <9u8gt6FvuuU1@mid.individual.net> (permalink)
References <17ygkeaa4yhfd$.1eiqrmk8tirx2$.dlg@40tude.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net nCnmKzscQz7d//X5JdL53AUNgneo03eS6aAQAZdCfoO9SH0K0W
Cancel-Lock sha1:YnklGL/9Uymvbd8Dm2tu18FDvrU=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120321 Firefox/11.0 SeaMonkey/2.8
In-Reply-To <17ygkeaa4yhfd$.1eiqrmk8tirx2$.dlg@40tude.net>
Xref csiph.com comp.lang.php:5357

Show key headers only | View raw


anver wrote:
> variable $temp is a path
> C:\www\site\test\folder\img.jpg
>
> if I write
> echo $temp;
> ok I have all the path
> ---------
>
> but if I use same variable in an alert I haven't more the correct path;
> haven't the \ slashs
>
> echo"<script type='text/javascript'>";
> echo "alert('$temp')";
> echo "</script>";
>
> I tested also string but is equal
> $temp=(string)$temp;
>
>
> is there a solution?

In most systems and scripting languages, the back slash '\' is an "escape" 
sign, for example \n is treated as new line, \t as tab, and this is what your 
javascript is doing and for a backslash to work, you need to use a double 
backslash '\\'.



-- 

   //Aho

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

variable path lose slashs when used in an alert anver <NOSPAMM@NO.SPAMMS> - 2012-04-06 17:05 +0200
  Re: variable path lose slashs when used in an alert "J.O. Aho" <user@example.net> - 2012-04-06 17:37 +0200
  Re: variable path lose slashs when used in an alert "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-07 13:30 +0200

csiph-web