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 Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/ 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 . ")"; Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/#findComment-304446 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? Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/#findComment-304448 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? Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/#findComment-304451 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 Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/#findComment-304454 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 Link to comment https://forums.phpfreaks.com/topic/61178-solved-not-entering-into-database/#findComment-304463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.