Reputation: 1621
I am trying to create a memory table in mysql through php but i keep getting an error:
Error creating database: 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 'Order INT)ENGINE = INNODB' at line 1
Below is the code that i am using to try and create it:
$sql = "CREATE TABLE Persons(FirstName CHAR(30),LastName CHAR(30),Age INT, Order INT)ENGINE = MEMORY";
if (mysqli_query($con,$sql))
{
echo "Database my_db created successfully";
}
else
{
echo "Error creating database: " . mysqli_error($con);
}
Upvotes: 1
Views: 1371
Reputation: 6138
Order
is a reserved word in sql, try replace it with other terminology.
Upvotes: 1
Reputation: 669
Make sure you are escaping the predefined constants in MySQL like 'order'
$sql = "CREATE TABLE `Persons`(`FirstName` CHAR(30),`LastName` CHAR(30),`Age` INT, `Order` INT)ENGINE = MEMORY";
See this post for more clarification:
Using backticks around field names
Upvotes: 4