| You are here: DEVPPL ‹ Forum ‹ Programming ‹ PHP and MySQL Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
posting prob from html forms to mysql
8 posts
• Page 1 of 1
0
posting prob from html forms to mysql
I'm having a problem with a news posting thing I set up. It works perfectly, except when you post news with a single or double quote in it.
I was wondering if anyone knew how to get around this.. its really annoying, cause you can't type things like can't due to the single quote.
Any help would be great!
Thanks
I was wondering if anyone knew how to get around this.. its really annoying, cause you can't type things like can't due to the single quote.
Any help would be great!
Thanks
- Driver
- Reputation: 0
- Posts: 3
- Joined: Thu Oct 14, 2004 6:24 am
- Highscores: 0
- Arcade winning challenges: 0
posting prob from html forms to mysql - Sponsored results
- Sponsored results
0
How are you having problems; whats the error?
When trying to enter data into the database does it stop at the first quote?
or
When you're grabbing data from the database do you always see something like this: \" or \' ?
Give an example of the problem, we'll give you better ways to solve it
When trying to enter data into the database does it stop at the first quote?
or
When you're grabbing data from the database do you always see something like this: \" or \' ?
Give an example of the problem, we'll give you better ways to solve it

- Malcolm
- Reputation: 0
- Posts: 198
- Joined: Thu Oct 07, 2004 10:53 pm
- Location: Ontario, Canada
- Highscores: 0
- Arcade winning challenges: 0
0
The prob is that unless you put \' or \" before a quote, then the php script that I wrote doesn't update the database properly, cause it ends at the quote.
I don't know how to tell php to ignore the single or double quote without the slash... or maybe to add the slash so mysql won't mess up ... I'm making this for users who I don't want to have to do much but type...
I don't know how to tell php to ignore the single or double quote without the slash... or maybe to add the slash so mysql won't mess up ... I'm making this for users who I don't want to have to do much but type...
- Driver
- Reputation: 0
- Posts: 3
- Joined: Thu Oct 14, 2004 6:24 am
- Highscores: 0
- Arcade winning challenges: 0
0
Post the script that's not working and will be much easier for us to help you.
And welcome to DEVPPL =)
And welcome to DEVPPL =)
[url=http://www.linkedin.com/profile/view?id=96243938]Meet me on LinkedIn[/url]
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
[img]http://www.devppl.com/images/facebook_icon_small.jpg[/img] Help DEVPPL grow, [url=http://www.facebook.com/pages/DEVPPL/140524279390050]like DEVPPL on facebook[/url]!
- Rasmus Lindström
- Site Admin
- Reputation: 18
- Posts: 2829
- Joined: Tue Aug 17, 2004 2:07 pm
- Location: Sweden
- Highscores: 1
- Arcade winning challenges: 0
0
Driver wrote:The prob is that unless you put \' or " before a quote, then the php script that I wrote doesn't update the database properly, cause it ends at the quote.
I don't know how to tell php to ignore the single or double quote without the slash... or maybe to add the slash so mysql won't mess up ... I'm making this for users who I don't want to have to do much but type...
Try something like this
**NOTE** People should be doing this whenever they enter _ANYTHING_ into the database thats from user input.
- Code: Select all
//where $string is the data to be entered into the database
if(get_magic_quotes_gpc()){
$string = stripslashes($string);
}
$string = mysql_real_escape_string($string);
Now try to enter the variable into the database, you shouldn't have any problems.
- Malcolm
- Reputation: 0
- Posts: 198
- Joined: Thu Oct 07, 2004 10:53 pm
- Location: Ontario, Canada
- Highscores: 0
- Arcade winning challenges: 0
|
|