Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Writing To Database Problem With Mysql - Not Writing Forum Post
beeseven
post Apr 3 2005, 05:32 AM
Post #1


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



I'm making a forum and I've had several problems tonight which I've come here to ask then found the answer to myself, but this one is stumping me. Whenever it goes to write the post to the database, it saves the poster, and the time, but the part where the message would go is empty. Here's the code, with comments about what it's supposed to do (what I wanted it to do and thought it did):
CODE
$imsg = stripslashes($_POST['msg']); //Get message
if(strlen($imsg) > 5 && strlen($imsg) < 10240) //Check length
{
 $imsg = htmlspecialchars($imsg); //Change stuff to entities
 $imsg = str_replace("&amp;","&",$imsg); //Change ampersands back
 $allowedentities = array('&lt;b&gt;','&lt;/b&gt;','&lt;i&gt;','&lt;/i&gt;','&lt;u&gt;','&lt;/u&gt;',
'&lt;B&gt;','&lt;/B&gt;','&lt;I&gt;','&lt;/I&gt;','&lt;U&gt;','&lt;/U&gt;','&lt;br&gt;',
'&lt;BR&gt;','&lt;Br&gt;','&lt;bR&gt;'); //Tell which entities to change into tags
 $allowedtags = array('<b>','</b>','<i>','</i>','<u>','</u>','<B>','</B>','<I>','</I>','<U>',
'</U>','<br>','<BR>','<Br>','<bR>'); //Tell which tags to turn them into
 $imsg = str_replace($allowedentities,$allowedtags,$imsg); //Replace
 $msg = nl2br($imsg); //Add line breaks
 echo "<table class=\"posts\"><tr><td class=\"msg\">$msg</td></tr></table><br>
<form method=\"post\" action=\"temppost.php\" name=\"f2\"><input type=\"submit\" name=\"post\"
value=\"Post Message\"></form>"; //Display preview of post and post button
}
That's how it takes the message and processes it. The rest is as follows:
CODE
$postedby = $username; //Get user posting
$postedon = date("F jS, Y \a\\t g:i:sa"); //Get date/time
mysql_query("INSERT INTO `tempposts` (`postedby`,`postedon`,`msg`) VALUES ('$postedby','$postedon','$msg')"); //Send it to database
I'm not sure if it's something about the $msg variable being available in the different parts or the mySQL table. I'm kind of new to it. The data type for the message was originally a BLOB, if that matters. I tried changing it to TEXT and it still didn't work.
Go to the top of the page
 
+Quote Post
mobious
post Apr 3 2005, 01:37 PM
Post #2


Advanced Member
*******

Group: Members
Posts: 113
Joined: 14-January 05
From: Philippines
Member No.: 3,271



i tested your srcipt by using my own database and substituted a fixed value for $imsg and $postedby. it worked for me so i am really wondering now what happened.
Go to the top of the page
 
+Quote Post
beeseven
post Apr 3 2005, 08:23 PM
Post #3


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



biggrin.gif I figured it out! I feel pround now (and a bit nerdy). The problem had to do with refreshing variables or something similar. I just had it store the message as a session variable, and then it was available to the second part to write to the database. Thanks mobious for figuring out it wasn't a mySQL problem.
Go to the top of the page
 
+Quote Post
mobious
post Apr 4 2005, 01:14 AM
Post #4


Advanced Member
*******

Group: Members
Posts: 113
Joined: 14-January 05
From: Philippines
Member No.: 3,271



QUOTE(beeseven @ Apr 4 2005, 04:23 AM)
biggrin.gif I figured it out! I feel pround now (and a bit nerdy). The problem had to do with refreshing variables or something similar. I just had it store the message as a session variable, and then it was available to the second part to write to the database. Thanks mobious for figuring out it wasn't a mySQL problem.
*



no prob! biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. **** Read Before You Post! ****(48)
  2. Halo 2 Glitches(51)
  3. Did You Face Problem Opening Pdf With Firefox?(15)
  4. Free Mmorpgs(62)
  5. Have You Ever Heard Discuz?(7)
  6. Quick Question(10)
  7. Aef Forum Modifications [resolved](3)
  8. How Did You Hear About This Forum(639)
  9. Pop-up Virus / Trojan Problem(10)
  10. Post Some Wierd Experiences At Night You've Had In Here.(4)
  11. Post Your Banners Here(7)
  12. Need Advice On Setting Up Mysql Database.(4)
  13. Firefox 3 Cookies Problem(4)
  14. Best Forum Ever I Found On Net(1)
  15. Forum News And Shoutbox On Homepage(4)
  1. Problem With The Trap17 Forum(4)
  2. [ Aef ] Security Update For Aef Forum Software(1)
  3. First Post In Over Two Years...(3)
  4. Attachment Problem In Pmwiki(0)
  5. What Is My (power) Problem?(4)
  6. Problem With Hosting(4)
  7. Welcome Post(4)
  8. Best Cms And Forum Combination(5)
  9. Heloo(4)
  10. Problem Concerning Credits Reduced(12)
  11. Forum Skin Never Shows(3)
  12. Problem With My Pc(2)
  13. Billing Problem. Plz Help(2)


 



- Lo-Fi Version Time is now: 12th October 2008 - 09:42 AM