?
Solved

Strip characters from right of string

Posted on 2004-09-16
2
Medium Priority
?
696 Views
Last Modified: 2012-05-05
Hi
I have entries in a mysql table that I read out, and then display on a page. The entries are the names of images, but some contain spaces in the name, eg. Image 234.jpg

What happens now is that I do this:
...
$pict = $myrow["picture"];
      if($pict) {
      $picture = trim($pict);
      $picture = rawurlencode($picture);
      // $picture = rtrim($picture, "%5C%22");
      }
...

For some reason, when I look at the source of the resulting page, there are "%5C%22" added to the end of the image name in the SRC line, causing the image not to be displayed.
As you can see, I tried an rtrim specifying these characters, but it does not remove them...

Any ideas?
0
Comment
Question by:psimation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 120 total points
ID: 12079455
Looks like a previous error when assigning name to image, because hex sequence correspond to:  \"
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 80 total points
ID: 12079471
%5C%22 urlencoded is \", so you might try

$picture = rawurlencode(preg_replace('/\\"$','',$picture));

to remove that garbage before you urlencode that string.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question