0

I am unable to insert integer data from insert statement.

$value = $_POST[from]; 
$query = mysql_query("INSERT INTO trip(tripid,from)VALUES(NULL, $value)");

Here from is integer value, but i am getting syntax error as :

You have an error in your SQL syntax;check the manual that corresponds to your MySQL server version for the right syntax to use near'from)VALUES(NULL, 1)'` at line 1.

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
  • 2
    `from` is a reserved keyword try: `INSERT INTO trip(tripid,``from``) VALUES (NULL, $value)` – itsmejodie Jan 16 '14 at 05:59
  • There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future. – Pang Jan 16 '14 at 06:40

1 Answers1

1

from is Reserved Words in MySQL http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-5.html

try this

mysql_query("INSERT INTO trip(tripid,`from`)VALUES(NULL, $value)");
naveen goyal
  • 4,571
  • 2
  • 16
  • 26