inserting data into DB problem
Posted: Thu Sep 08, 2005 7:39 pm
hello, i found a bit of code, something like bbcode and modified it a little to what i need.
the problem is that I have no ideea (and i tried a few) howw to assign the function to a variable and insert it into db.
here is a piece.
this displayes ok,but how do i enter the data into db?
thx
the problem is that I have no ideea (and i tried a few) howw to assign the function to a variable and insert it into db.
here is a piece.
Code: Select all
function replaceMessage($post) {
$post = str_replace ("[u]", "<u>", "$post");
$post = str_replace ("[/u]", "</u>", "$post");
$post = str_replace ("[i]", "<i>", "$post");
$post = str_replace ("[/i]", "</i>", "$post");
$post = str_replace ("[b]", "<b>", "$post");
$post = str_replace ("[/b]", "</b>", "$post");
$post = str_replace ("[size=1]", "<font size='1'>", "$post");
$post = str_replace ("[size=2]", "<font size='2'>", "$post");
$post = str_replace ("[size=3]", "<font size='3'>", "$post");
$post = str_replace ("[size=5]", "<font size='5'>", "$post");
$post = str_replace ("[size=7]", "<font size='7'>", "$post");
$post = str_replace ("[/size]", "</font>", "$post");
$post = str_replace ("[color=maroon]", "<font color='maroon'>", "$post");
$post = str_replace ("[color=red]", "<font color='red'>", "$post");
$post = str_replace ("[color=navy]", "<font color='navy'>", "$post");
$post = str_replace ("[color=blue]", "<font color='blue'>", "$post");
$post = str_replace ("[color=teal]", "<font color='teal'>", "$post");
$post = str_replace ("[color=green]", "<font color='green'>", "$post");
$post = str_replace ("[color=olive]", "<font color='olive'>", "$post");
$post = str_replace ("[color=white]", "<font color='white'>", "$post");
$post = str_replace ("[color=silver]", "<font color='silver'>", "$post");
$post = str_replace ("[color=gray]", "<font color='gray'>", "$post");
$post = str_replace ("[color=black]", "<font color='black'>", "$post");
$post = str_replace ("[/color]", "</font>", "$post");
return $post;
}
echo replaceMessage($post);
}Code: Select all
$sql = mysql_query("INSERT INTO table(field) VALUES('".$what_comes_here?."')");