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?
Best way to submit text into MySQL?
1 reply to this topic
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)
<?php $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