Ryuujin Posted July 22, 2007 Share Posted July 22, 2007 Hello, I have been trying to figure this out for about 3 hours now and I can't fix it for nothing. Here is the code were it inserts into the database: if ($page =='messages' & $action == 'sendmessage2') { $sentto = mysql_real_escape_string($_POST['sentto']); $from = $_SESSION[username]; $senton = 'NOW()'; $title = mysql_real_escape_string($_POST['title']); $message = mysql_real_escape_string($_POST['message']); mysql_query("INSERT INTO messages (sentto, from, senton, title, message) VALUES ('$sentto', '$from', '$senton', '$title', '$message')"); echo "Message Sent, <a href=index.php?page=messages>Continue</a>"; } Ok, I think that is the origin of the problem. If you need the form just tell me. Now, the database table has all those so I don't think it is the database. Any help is greatly appreciated. Thanks, -Ryuujin Quote Link to comment Share on other sites More sharing options...
wsantos Posted July 22, 2007 Share Posted July 22, 2007 try this... mysql_query("INSERT INTO messages (sentto, from, senton, title, message) VALUES (" . $sentto . "," . $from . ", ' . $senton "," . $title . "," . $message . ")"; Quote Link to comment Share on other sites More sharing options...
Ryuujin Posted July 22, 2007 Author Share Posted July 22, 2007 Hmm, nope. No luck. Any other ideas? Quote Link to comment Share on other sites More sharing options...
wsantos Posted July 22, 2007 Share Posted July 22, 2007 ok lets do this one by one... is the table messages contain only the fields sentto, from, senton, title, message? assign the query to another variable first and test if it got the right string...like this $strQuery = "INSERT INTO messages (sentto, from, senton, title, message) VALUES (" . $sentto . "," . $from . ", ' . $senton "," . $title . "," . $message . ")"; echo $strQuery; then post the output...is it the query you want? Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 22, 2007 Share Posted July 22, 2007 FROM is a MySQL reserved word - http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html Avoid using reserved words as table names or field names. Change the field named from to one named x_from and change your query to match Quote Link to comment Share on other sites More sharing options...
wsantos Posted July 22, 2007 Share Posted July 22, 2007 aw i didn't notice that...andyB help on my topic please...thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.