For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > February 2006 > apostrophe nightmare









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author apostrophe nightmare
sub@drewpydraws.com

2006-02-18, 6:55 pm

Having a weird problem.

Here's the call:

DBAddBlog($blog, $today);


And here's the function
/ ****************************************
*******************
* FUNCTION: DBAddBlog($blog, $today)
*
* DESCRIPTION: adds the blog
*
* RETURNED: nothing
****************************************
******************/
function DBAddBlog($blog, $today)
{
mysql_query("UPDATE `table` SET `id` = '3' WHERE `id` =2");
mysql_query("UPDATE `table` SET `id` = '2' WHERE `id` =1");
mysql_query("INSERT INTO `table` ( `id` , `date` , `blog` ) VALUES ('1',
'$today', '$blog')");
mysql_query("DELETE FROM `table` WHERE `id` ='3' ");
}



Everything get's run except for the INSERT INTO if there is an apostrophe in
the value $blog. If I replace the apostrophe with ' it works fine.

On my server I'm running PHP 4.4 and mySQL 4.1.16. I design there and
publish elsewere. On my server everything works fine all the time, but on
the production server I'm running PHP 4.3.11 and MySQL 4.1.12 that's where
i'm having problems with the apostrophe.

~Drew
www.drewpydraws.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com