[ciapug] Cleaning data for db storage

Dave J. Hala Jr. ciapug@cialug.org
19 Mar 2004 09:45:08 -0600


You should be able to insert those characters, if they are escaped. 
Here's a little snippet of how I do my PHP/Mysql inserts:


	$connection = db_connect("Couldnt Connect to the Database");

	$SQL="INSERT mytable (AFN, MMO) VALUES ( \"$afn\", \"$mmo\" )";

	$result= mysql_query($SQL,$connection) or die (mysql_error());


On Fri, 2004-03-19 at 09:35, Chris Hettinger wrote:
> For the best results what should I do to deal with unfriendly characters 
> submitted in form data when the data is going to be store in a database?
> 
> My current situation is that I have to do something about the apostrophe 
> and ampersand used in text fields because it is causing errors when that 
> data is put through a db insert or update statement.
> 
> I can't strip them completely, is there a "best practice" to follow when 
> dealing with this? How do others work with them?
> 
> -ch
> _______________________________________________
> ciapug mailing list
> ciapug@cialug.org
> http://cialug.org/mailman/listinfo/ciapug
-- 

"...Unix, MS-DOS and Windows NT (also known as the Good, the Bad, and the Ugly)"

OSIS
Dave J. Hala Jr.
641.485.1606