PHP/mySQL Help Needed

Hi. I need to run a query to find all occurances of "ipbhost.com" in a certain field of a table and replace it with "net" because the domain for my site has changed.

Here is the relevent section of the code I'm trying to use.

$sql_query "SELECT pid, post FROM ipb_posts";

$DB->query( $sql_query );

while ( $row = $DB->fetch_row() )
{
//echo ($row['pid'].",".$row['post']);
//echo ("<br />");

$post = str_replace("ipbhost.com","net",$row['post']);

//
// Need Help to Format this UPDATE command properly Please
//
$sql_command = "UPDATE ipb_posts SET post = '".$post."' WHERE pid = ".$row[pid];

// Doesn't work because the sql_command seems to have lots
// of ", ', and other stuff in it that screws up the update
// yet I want to keep these characters in the data
$UPDATER->query($sql_command);

// HELP!

}

The problem seems to be that $post has some ' and or "s in it that are messing up the SQL command. Yet, I want to keep those characters not throw them out.

I apologize is this is more of a mySQL question than a PHP question, but can anyone tell me the answer ?

Thanks!
[1325 byte] By [Mutilated1] at [2007-11-19 1:36:15]
# 1 Re: PHP/mySQL Help Needed
use two str_replace calls for ' and " after yours:

$post=str_replace("\'","\\\'",$post);
$post=str_replace("\"","\\\"",$post);
However I think the second call is not necessary.
Tleilaxu at 2007-11-10 3:58:51 >
# 2 Re: PHP/mySQL Help Needed
or u can use addslashes() ( http://www.php.net/manual/en/function.addslashes.php) which does the same as above, but in one call.
PallaviDalvi at 2007-11-10 3:59:50 >
# 3 Re: PHP/mySQL Help Needed
Thank you. addslashes worked nicely.
Mutilated1 at 2007-11-10 4:00:49 >
# 4 Re: PHP/mySQL Help Needed
I downloaded a forum from the http://www.phpbb.com
I set it up and it works, but:

my probelm is that when somebody wants to register, he'll get an e-mail, where he has to activate his account. For some reasons, the e-mail isn't sent and I've got some error avout SMTP.

What can I do?
zolta at 2007-11-10 4:01:54 >
# 5 Re: PHP/mySQL Help Needed
Does you mail service work?
Danii at 2007-11-10 4:02:59 >