Jump to content


Best way to submit text into MySQL?

  • Please log in to reply
1 reply to this topic

#1 DaveLinger

  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 07 August 2006 - 01:21 AM

I'm beginning to run into some SQL problems... I have a text area in which the user can enter text and upon submission it is added to a "text" column in my mysql db. The problem is quotes (among other things) screw it up. How can I get around that?
dave at linger dot com

#2 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 07 August 2006 - 01:29 AM

Use the function mysql_real_escape_string() on all text fields that will be stored in a MySQL database. (http://www.php.net/m...l_escape_string)

$q = "insert into yourtable set fieldname1 = '" . mysql_real_escape_string($your_variable) . "'";
$rs   = mysql_query($q) or die("Problem with query: $q<br>" . mysql_error());


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users