I have error to add information for one of my database. I try to echo out the $sql to see whether it will echo out i try, and it display.After i try to find the mysql_error and it display this
i not sure what is the error, as for other page, i aso use about the same code, the only different is the name of the database and variable name and i able to insert into database. but i not sure why this is not working??? please help!!!INSERT INTO place ( id, from, place, to, description ) VALUES ( '55', 'D', 'D', 'D', 'D')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, 'place', 'to', 'description' ) VALUES ( '55', 'D', 'D', 'D', 'D')' at line 1
This is my php code
Code: Select all
<?php
require('db.php');
//retrieve the information from html form
$d = $_POST['id'];
$from = $_POST['from'];
$place = $_POST['place'];
$to = $_POST['to'];
$description = $_POST['description'];
//connect to DB server
mysql_connect(MACHINE, USER, '');
mysql_select_db(DBNAME);
//prepare the sql query
$sql = "INSERT INTO place ( id, from, place, to, description ) VALUES ( '".$id."', '".$from."', '".$place."', '".$to."', '".$description."')";
echo $sql;
// mysql_query($sql);
mysql_query($sql) or die (mysql_error());
echo "<a href = 'try.php'>Go back to the page</a>";
?>