Jump to content

Archived

This topic is now archived and is closed to further replies.

DaveLinger

Best way to submit text into MySQL?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Use the function mysql_real_escape_string() on all text fields that will be stored in a MySQL database. (http://www.php.net/mysql_real_escape_string)

Example:
[code]<?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());
?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.