|
Posted by Jerry Stuckle on 09/22/07 22:35
dkirkdrei@yahoo.com wrote:
> On Sep 22, 3:43 pm, gosha bine <stereof...@gmail.com> wrote:
>> dkirkd...@yahoo.com wrote:
>>
>>> the code:
>>> <?
>>> $var = "\\wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
>>> echo strtr($var, array('\\' => '\\\\'));
>>> ?>
>>> produces this:
>>> \\wusais\\Intranets\\Intranets\\fpdb\\pdf\\weinig 05882.pdf
>>> close but the end is still killing me...
>> If the string is coming from DB as you have said, you shouldn't be
>> assigning it to $var, but fetch it from the database instead, like this:
>>
>> $rc = mysql_query("SELECT .....");
>> $row = mysql_fetch_array($rc);
>> $var = $row['fieldname'];
>>
>> echo strtr($var, array('\\' => '\\\\'));
>>
>> --
>> gosha bine
>>
>> extended php parser ~http://code.google.com/p/pihipi
>> blok ~http://www.tagarga.com/blok
>
> Ok, I appreciate all the feed back but maybe I need to post exactly
> what I am trying to accomplish.
> My variable is coming from a select statement out of a Access db via
> an ODBC connection. As it stands right now, I am
> using the following code:
>
> <form method="post" action="<?echo $dwg;?>" target="_blank">
> <td><p align="center"><button name="open" value="none"
> type="submit">open</button></td>
> </form>
>
> the variable $dwg is my windows file path that is structured like "\
> \wusais\Intranets\Intranets\fpdb\pdf\weinig\00505882.pdf";
> this code works fine, the user clicks the button and a new window
> opens displaying the file. I would like to control the window that the
> file is opened in so I have to pass the php variable over to
> javascript. If I pass it directly to the code below without doubling
> the slashes, the file does not open. I have manually doubled the
> slashes on a couple of the records in the db and everything works
> fine.
>
> javascript code that takes the place of the code posted above:
>
> <form>
> <input type="button" onclick="javascript:window.open('<?echo $test;?
>> ','window','width=800,height=600,resizable=yes,scrollbars=yes,status=no,toolbar=no')"
> value="open">
> </td>
> </form>
>
> so either I have to change all the records in the db or somewhere
> between the db and the javascript the slashes have to be doubled??
>
As we've been trying to tell you. Use the techniques posted to modify
the string after you get it from the database but before you echo it to
the screen for your javascript.
You don't have to double the backslashes in the database - in fact, you
shouldn't. Just try it - and if it doesn't work, post the exact PHP
code you're using with one of the suggestions installed.
Personally I like the str_replace version. It only works with one
string at a time while gosha's can replace multiple string. But mine
is faster when dealing with a single string.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|