You are here: DEVPPL Forum Programming PHP and MySQL Forum
NOTIFICATIONS
54.087
MEMBERS
15.684
TOPICS
62.255
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

posting prob from html forms to mysql

0

Loading

posting prob from html forms to mysql

Postby Driver » Thu Oct 14, 2004 6:28 am

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
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

Login to get rid of ads

 

0

Loading

Postby Adl » Thu Oct 14, 2004 11:16 am

str_replace should work, but then you'll also have to make sure that you close the tags...
Adl
 
Reputation: 0
Posts: 29
Joined: Sun Sep 19, 2004 5:11 pm
Location: Finland
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Malcolm » Thu Oct 14, 2004 1:12 pm

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 :)
Image
Malcolm
 
Reputation: 0
Posts: 198
Joined: Thu Oct 07, 2004 10:53 pm
Location: Ontario, Canada
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Driver » Thu Oct 14, 2004 4:10 pm

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...
Driver
 
Reputation: 0
Posts: 3
Joined: Thu Oct 14, 2004 6:24 am
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Rasmus Lindström » Thu Oct 14, 2004 4:54 pm

Post the script that's not working and will be much easier for us to help you.

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]!
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2830
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Malcolm » Thu Oct 14, 2004 11:57 pm

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
0

Loading

Postby Driver » Sat Oct 16, 2004 1:53 am

ok, thanks a ton!
Driver
 
Reputation: 0
Posts: 3
Joined: Thu Oct 14, 2004 6:24 am
Highscores: 0
Arcade winning challenges: 0
0

Loading

Postby Malcolm » Sat Oct 16, 2004 5:37 am

Don't forget to mark this topic as solved :)
Image
Malcolm
 
Reputation: 0
Posts: 198
Joined: Thu Oct 07, 2004 10:53 pm
Location: Ontario, Canada
Highscores: 0
Arcade winning challenges: 0
^ Back to Top