If anyone can help... much appreciated.
I am trying to create a simple html form to submit a table into a datebase with pre-populated columns. Upon submisson, I get a syntax error. I have tried using single quotes and not using single quotes for the table name, which is where the error is originating. I believe it is due to using $ but I cannot figure out another way to get the table name from my html form.
My html form code:
<form action="insert.php" method="post">
Project Name: <input type="text" name="Project" size="50"><br>
my inpsert.php code:
$username = "root";
$password = "XXXXX";
$database = "Project_Data";
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE $Project (
'Id' tinyint(1) NOT NULL auto_increment,
'Description' varchar(50) NOT NULL default '',
'File' varchar(50) NOT NULL default '',
PRIMARY KEY (Id)
INSERT INTO 'pageheaders' VALUES ($Project);";
print 'DB error ' . mysql_error();
Print "$Project has been successfully added to the database.";
The sql syntax error message:
DB error 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 'Project ( 'Id' tinyint(1) NOT NULL auto_increment, 'Description' varchar(50)' at line 1
Or with single quotes for table name:
DB error 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 ''First Project' ( 'Id' tinyint(1) NOT NULL auto_increment, 'Description' var' at line 1
Thanks in advance for any help.
- Hal W