There is a form in the form of login, email, message. After the introduction, the handler does its work, but does not enter anything in the database. But, if you display a variable on the screen, they are displayed. The same query, but with different values ​​works fine on another page. What is the problem?

In the database field: ID(ai) , FROM , MESSAGE , EMAIL , WHOM .

Code:

 <?php $from = trim($from); $ban_email = trim($ban_email); $text_banned = trim($text_banned); echo $from ,$ban_email,$text_banned ; $result = mysql_query("INSERT INTO messages (from,message,whom,email) VALUES ('$from','$text_banned','$from','$ban_email')"); ?> 
  • By DB is included - angers777
  • POST sends - angers777
  • here so to write, the religion does not allow? Let's see what die says: $ result = mysql_query ("INSERT INTO messages (from, message, whom, email) VALUES ('$ from', '$ text_banned', '$ from', '$ ban_email')") or die (mysql_error ()); - Vfvtnjd
  • You have an error in your SQL syntax; check the syntax for the right syntax to use for the user’s account , the email message, the VALUES ('Login', 'Message', 'Login', 'Email') 'at line 1 - angers777
  • I think that I don’t like from ([I won’t explain where it is usually used] [1]) [1]: dev.mysql.com/doc/refman/5.0/en/select.html - Vfvtnjd

2 answers 2

How much do you need to learn?

  $result = mysql_query("INSERT INTO messages (from,message,whom,email) VALUES ('".$from.",'".$text_banned."','".$from."','".$ban_email."')"); // кавычки 

When quotation mark put, do not be lazy !!!

    Field names must be put in ``, and values ​​in ''