Solved

Strip characters from right of string

Posted on 2004-09-16
2
692 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 30 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 20 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 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