Could someone please tell me what is wrong with this bunch of very simple SQL code below? I'm trying to use PHP and mysql.
// Create table
$tname=$_POST["appname"];
$creatt="CREATE TABLE $tname
(
AppVersion VARCHAR(30),
AppType VARCHAR(30),
FileName VARCHAR(255),
AppSize FLOAT,
sizetype VARCHAR(30),
apppart FLOAT,
appLRadress VARCHAR(255),
appSRadress VARCHAR(255),
appRadress VARCHAR(255),
apptahye DATE(),
appupload DATE(),
appfenally DATE(),
status CHAR(30),
applearn CHAR(30),
applearnadd VARCHAR(255),
applearnudate DATE(),
learntype VARCHAR(30),
appcrack CHAR(30),
appcrackadd VARCHAR(255),
appcrackdate DATE(),
cracktype CHAR(30)
)";
// Execute query
if (mysqli_query($con,$creatt))
{
echo "Table $tname created successfully";
}
else
{
echo "Error creating table: " . mysqli_error($con);
}
This error occurs:
Error creating table: 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 'photoshop ( AppVersion VARCHAR(30), AppType VARCHAR(30), FileName VARCHAR' at line 1
But when I use less columns like this:
$tname=$_POST["appname"];
$creatt="CREATE TABLE `$tname`(FirstName CHAR(30),LastName CHAR(30),Age INT)";
it works!!!!
What is wrong with my columns?