| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
is scientific.
Resident.
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,117 posts
Gave thanks: 8
Thanked 34 times
|
quote's...---> ' <--- that one in particular
Ok, so when I retrieve something from the database that has a single quote in it (like the phrase I'm going to go home) it stops the display right before the quote. So like, I'm going to go home would display only I. Why? And how to I fix that? It's only doing it in a text field, but not a text area.
|
|
|
|
|
|
#2 (permalink) |
|
is scientific.
Resident.
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,117 posts
Gave thanks: 8
Thanked 34 times
|
Note, this is when I'm retrieving the data into a form that I will use to edit it with. The data has already been inserted, this is just an editing tool.
|
|
|
|
|
|
#3 (permalink) |
|
All Ur Base R Belong 2 Us
Excelling Contributor
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
|
Have you checked phpMyAdmin to make sure that the entire sentence is stored in the row?
Time for prison breakkkk, i'll b back
__________________
Nobody doing nothing |
|
|
|
|
|
#4 (permalink) |
|
Skittles
Super #1
Joined in Aug 2004
Lives in a space ship
Hosted on dedi
6,815 posts
Gave thanks: 101
Thanked 199 times
|
I think you have to put a \ in front of the quote, so php won't think it is the end or beginning of something (it might be the /.... I am not sure..)... or.. something
__________________
Mountain Dew Knight
People should not be afraid of their governments. Governments should be afraid of their people. |
|
|
|
|
|
#5 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,086 posts
Gave thanks: 48
Thanked 131 times
|
Odd that it's doing that... Have you checked the actual database to see whether the data is complete or not inside like Mr Fern suggested? My guess is that it wasn't escaped properly in the first place.
|
|
|
|
|
|
#6 (permalink) |
|
Surpass Fan
Super #1
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
|
Just a guess, but I think it's on the HTML side. Do you have your text field like this?
Code:
<input type="text" value='foobar' />
__________________
- Evan Charlton | [site] | Server - SH58 |
|
|
|
|
|
#7 (permalink) |
|
is scientific.
Resident.
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,117 posts
Gave thanks: 8
Thanked 34 times
|
Well, that sort of worked. Now I have the whole I'm but nothing else in the sentence. It does save to the database as I'm the enemy of Paris Hilton, but won't seem to come back out into the text box as that way. The text area, I have no problem with. That brings up everything like it should, quotes or not.
Alright, I just tested something. When I remove the quote with a string replace using the the variable in double quotes (ie: "$something"), than it brings up only that word, much like what I just mentioned but without the quote now. But, when I do it in the way it was originally written, and remove the quote, it comes up fine, just without that quote: PHP Code:
Im the enemy of Paris Hilton I tried adding a slash before it, but that just ended up with the letter I having a slash next to it. Ah, Prison Break. I shall be watching that too in about 18 minutes and 20 seconds. |
|
|
|
|
|
#8 (permalink) |
|
All Ur Base R Belong 2 Us
Excelling Contributor
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
|
If you view the HTML source of the PHP generated page, you'll see the entire sentence in the source... the reason it doesn't show up in the text field is because you're using that quote to define the value.
<input type='text' name='title' value='$title' size='100'> with the title being: I'm happy transforming into <input type='text' name='title' value='I'm happy' size='100'> So the only value you'll see is: I Your solution involves adding the following in place of that str_replace: $title = htmlentities($title, ENT_QUOTES); that function converts all special characters into their equivalent codes (copyright symbol, ampersand, <, >, etc.) htmlentities($value, ENT_QUOTES) will convert both single and double quotes. The default htmlentities($value) converts double quotes only, and htmlentities($value, ENT_NOQUOTES) leaves all quotes alone.
__________________
Nobody doing nothing |
|
|
|
|
|
#9 (permalink) |
|
is scientific.
Resident.
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,117 posts
Gave thanks: 8
Thanked 34 times
|
Awesome. That fixed it. And you're right, it was showing in the source, just not in the box. I'll have to bookmark this to remember it.
|
|
|
|