GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   MySQL easy syntax question (https://gfy.com/showthread.php?t=897766)

Socks 04-03-2009 11:51 PM

MySQL easy syntax question
 
update category_text set text='this is a problem because it's got an apostrophe in it', keywords='asdf,asdf' where id='1';

Just that the string I want to insert has an apostrophe.. Is that going to mess the syntax up?

jMEGA 04-04-2009 12:14 AM

try this

update category_text set text='this is a problem because it\'s got an apostrophe in it', keywords='asdf,asdf' where id='1';

Socks 04-04-2009 12:53 AM

Nice thanks!! Now I know why I've seen those things printed around my site sometimes heh

V_RocKs 04-04-2009 01:52 AM

google for php html entities

nation-x 04-04-2009 08:01 AM

if this is for a php script then you can just use http://us3.php.net/mysql_real_escape_string

Code:

$sql = "update category_text set text='".mysql_real_escape_string("this is a problem because it's got an apostrophe in it")."', keywords='asdf,asdf' where id='1';"

$affected_rows = mysql_query($sql);



All times are GMT -7. The time now is 03:30 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123