Question: pretty simple code in php and mysql:

code inserting data in mysql table :

```
<?php

include("config.php");

$sql="INSERT INTO messages_sent (to) VALUES (35)";

$result=mysql_query($sql);

if(!$result)
{
    echo("<br>Sorry the message could not be inserted into table messages_sent</br><br>");
    die(mysql_error());     
}else{      
    echo("<br>Message Inserted</br>");
}    

?>

```

table creation code follows:

```
$sql="CREATE TABLE IF NOT EXISTS `messages_sent`(
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`to` INT(11) NOT NULL,
`from` INT(11) NOT NULL,
`msg` TEXT NOT NULL,
`viewed` TINYINT(2)NOT NULL,
`time` DATETIME NOT NULL
)";

$result=mysql_query($sql);

if(!$result)
{
    echo("Sorry the create query for table messages_sent could not be executed ");
    die(mysql_error());     
}

```

if i insert data in msg column, it is no prob but if the column is `to` or `from` then syntax error problem occurs.

Solution?

Answer: 
in the schema of your table, you are setting `NOT NULL` with none `DEFAULT` value to other fields. so basically you cannot execute

`INSERT INTO messages_sent (to) VALUES (35)` 

because you are leaving other fields `NULL` and ALSO `FROM` and `TO` are [Reserved Word](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) in mySQL. Or instead use back ticks ``` inside your query.

ex.

```
INSERT INTO `tableName` (`colName`) VALUES (valueHere)

```
`from` is keyword use back ticks like this `from`