Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

urlencode problem (newbie)

Status
Not open for further replies.

gbaker

MIS
Nov 27, 2001
77
US
I'm having a problem that tells me I'm about 10 seconds away from fixing it with urlencode and rawurlencode.
I'm trying to use either of those functions to encode records returned in a data set that contain spaces in paths to file names.

Here's the code that I'm using:
<a href = &quot;rawurlencode ('.$row[&quot;ImgPath&quot;] .')&quot; / &quot;rawurlencode('.$row [&quot;Filename&quot;].')&quot;>
<img src =&quot;rawurlencode('.$row [&quot;Thumbpath&quot;].')&quot; / &quot;rawurlencode('.$row [&quot;Filename&quot;].')&quot; border = 0> </a>

This returns:

I know that the syntax is very close, as it's encoding the path, but it's returning in the wrong syntax.
Any suggestions would be appreciated.
 
one way:
<a href = '&quot;<?=(rawurlencode ($row
).&quot; / &quot;.rawurlencode($row [&quot;Filename&quot;]))?>'&quot;>

the other
<?
$link=rawurlencode($row [&quot;Thumbpath&quot;]).&quot; / &quot;.rawurlencode($row [&quot;Filename&quot;]);
?>
<img src =&quot;<?=$link?>&quot; border = 0> </a>


Known is handfull, Unknown is worldfull
 
Thanks for the reply, I tried your sample but got unexpected '&quot; errors. Here's the full chunk of code:

<%while ($row = mysql_fetch_array($result, MYSQL_ASSOC))

Echo ('

<TD Width = &quot;600&quot; align = justify> <Font face = &quot;Garamond&quot; color = &quot;#FFCE53&quot; size = &quot;5&quot; >
<em> '.$row [&quot;Description&quot;].' </em>
</TD>
<TD align = center> <a href = &quot;rawurlencode('.$row[&quot;ImgPath&quot;].')&quot; / &quot;.rawurlencode('.$row [&quot;Filename&quot;].')target = _new> <img src =&quot;rawurlencode('.$row [&quot;Thumbpath&quot;].')&quot; / &quot;rawurlencode('.$row [&quot;Filename&quot;].')&quot; border = 0> </a>
</TD>
</TR>
<TR>
<TD >
<HR> </HR>
</TD>


</TR>
')
%>

I think the big problem that I'm having revolves around the &quot;Echo&quot; .
 
sorry i didnt know u used echo.
the problem with echo is that:

echo('$name'); //will print $name.
echo(&quot;$name&quot;); //will print the value of $name.

therefore if u plan to use any variable in echo use double qoutes...

try this:
Echo ('

<TD Width = &quot;600&quot; align = justify> <Font face = &quot;Garamond&quot; color = &quot;#FFCE53&quot; size = &quot;5&quot; >
<em> '.$row [&quot;Description&quot;].' </em>
</TD>
<TD align = center> <a href = &quot;'.rawurlencode($row[&quot;ImgPath&quot;]).' / '.rawurlencode($row [&quot;Filename&quot;]) .'target = _new> <img src =&quot;'.rawurlencode($row [&quot;Thumbpath&quot;].).' / '.rawurlencode($row [&quot;Filename&quot;]).' border = 0> </a>
</TD>
</TR>
<TR>
<TD >
<HR> </HR>
</TD>


</TR>
');

and why not use simple echo stmts?


Known is handfull, Unknown is worldfull
 
sorry try this:
echo('
<TD Width = &quot;600&quot; align = justify> <Font face = &quot;Garamond&quot; color = &quot;#FFCE53&quot; size = &quot;5&quot; > ');
echo('<em> '.$row [&quot;Description&quot;].' </em>');
echo('</TD><TD align = center>');
echo('<a href = &quot;'.rawurlencode($row[&quot;ImgPath&quot;]) .' / '. rawurlencode($row [&quot;Filename&quot;]) .'&quot; target = _new> ');
echo('<img src =&quot;'.rawurlencode($row [&quot;Thumbpath&quot;].).' / '.rawurlencode($row [&quot;Filename&quot;]).' border = 0> </a>');
echo('
</TD>
</TR>
<TR>
<TD >
<HR> </HR>
</TD>


</TR>
');



Known is handfull, Unknown is worldfull
 
Thanks, I'll give that a try, looks much simpler than what I was trying to do in bulk. As I said, I'm a newbie and that can be a dangerous thing.
 
or a simpler method:
<TD Width = &quot;600&quot; align = justify> <Font face = &quot;Garamond&quot; color = &quot;#FFCE53&quot; size = &quot;5&quot; ><em><?=$row [&quot;Description&quot;]?> </em></TD>
<TD align = center><a href = &quot;<?=rawurlencode($row[&quot;ImgPath&quot;]).&quot;/&quot;. rawurlencode($row [&quot;Filename&quot;])?>&quot; target = _new>
<img src =&quot;<?=rawurlencode($row [&quot;Thumbpath&quot;].' / '.rawurlencode($row [&quot;Filename&quot;])?>&quot; border = 0> </a> </TD>
</TR>
<TR>
<TD >
<HR> </HR>
</TD>


</TR>


please come back if there are any errors...

NOTE: this method is supposed to be a bit slower(no one knows how much) than using echo statements...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top