Solved

Strip characters from right of string

Posted on 2004-09-16
2
647 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to count occurrences of each item in an array.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now