icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » quote's...---> ' <--- that one in particular

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 28th, 2005, 5:27 PM   #1 (permalink)
is scientific.
Resident.
 
David's Avatar
 
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.
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 28th, 2005, 5:54 PM   #2 (permalink)
is scientific.
Resident.
 
David's Avatar
 
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.
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 28th, 2005, 8:56 PM   #3 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
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
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 28th, 2005, 9:13 PM   #4 (permalink)
Skittles
Super #1
 
DewKnight's Avatar
 
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.
DewKnight is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 28th, 2005, 11:47 PM   #5 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
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.
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 29th, 2005, 12:51 AM   #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' />
If so, then change value='foobar' to double quotes: value="foobar"
__________________
- Evan Charlton | [site] | Server - SH58
Kickersny.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 29th, 2005, 11:15 AM   #7 (permalink)
is scientific.
Resident.
 
David's Avatar
 
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:
while ($row mysql_fetch_array($result))
{
extract($row); 
$title str_replace("'"""$title); 
echo 
"<form name='edit_post' method='post' action='edit_post.php'>
Title<br>
<input type='hidden' name='pid' value='$pid'>
<input type='text' name='title' value='$title' size='100'>
<br/><br/>
Content<br/>
<textarea name='post' rows='15' style='width: 98%'>$post</textarea>
     <br/><br/>
<input type='submit' name='edit_post' value='Submit' id='edit_post'>
</form>"
;

Would result in:

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.
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 29th, 2005, 12:52 PM   #8 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
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
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 29th, 2005, 1:00 PM   #9 (permalink)
is scientific.
Resident.
 
David's Avatar
 
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.
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On