Hi, I'm strugling with a problem that I don't understand.
[what I'm doing] I'm writing my own simple blog script [/what I'm doing]
[my problem]I'm struggling with with implimenting a smilies system
[in more detail]
Well I wrote a simple page that would alow you to add to the DB I'm using via a form. That worked, but in order to have the text smilies changed to <img> tags I had to replace (via str_replace() function) ":-)" to "<img src='/blog/smilies/smilie.gif'>".
When I added the str_replace() stuff the DB part stoped working.
Why is that? Here's the code I'm trying to get to work.
<?php
$DB_SERVER = "localhost";
$DB_USER = "xxxxxx";
$DB_PASS = "xxxxxx";
$DB_NAME = "xxxxx";
$Blog_TABLE = "xxxx";
$db = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS);
mysql_select_db($DB_NAME);
if ($submit) {
// process form
$code = array(":)", ":-)", "=)");
$tag = array("<img src='http://www.mikestermedia.com/blog/smilies/smilie.gif'>",
"<img src='http://www.mikestermedia.com/blog/smilies/smilie.gif'>",
"<img src='http://www.mikestermedia.com/blog/smilies/smilie.gif'>");
$blog = str_replace($code, $tag, $blog);
$db = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS);
mysql_select_db($DB_NAME);
$result = mysql_query("SELECT * FROM $Blog_TABLE",$db);
$sql = "INSERT INTO $Blog_TABLE (blog) VALUES ('$blog')";
$result = mysql_query($sql);
echo "Thanks! It's been bloged.";
}
else{
// display form
?>
<H1Add a Blog</H1>
<BR>
<form method="post" action="<?php echo $PHP_SELF?>">
Blog:<br>
<textarea name="blog" cols=40 rows=8></textarea><br>
<input type="Submit" name="submit" value="Blog It!">
</form>
<?php
} // end if
?>
Could anyone help me? This is driving me nuts! Thanks in advance