having a bit of an issue inserting some data into one of my mysql tables using php post from a html site. Keeps getting an error msg stating
"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 'table,type,email) VALUES ('0','Jan','1','2009','v','c','xz','Maintenance','z')' at line 1 "
after i run the submit. I don't see any problems in code and if I edit the html page and php page to post into a different database only using 3 text boxes it seems to work fine.
Any advice would be helpfull thank you.
Test2.html page
insert.php page
I know it looks plain and simple right now but want to get it working before i start putting the css and graphics into it.
"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 'table,type,email) VALUES ('0','Jan','1','2009','v','c','xz','Maintenance','z')' at line 1 "
after i run the submit. I don't see any problems in code and if I edit the html page and php page to post into a different database only using 3 text boxes it seems to work fine.
Any advice would be helpfull thank you.
Test2.html page
Code:
<html>
<head>
</head>
<body>
<form action='insert.php' method='post'>
<p style='margin-bottom:0;'>Date</p>
<select name='mon'>
<option value='Jan'>Jan</option>
<option value='Feb'>Feb</option>
<option value='Mar'>Mar</option>
<option value='Apr'>Apr</option>
<option value='May'>May</option>
<option value='June'>June</option>
<option value='July'>July</option>
<option value='Aug'>Aug</option>
<option value='Sept'>Sept</option>
<option value='Oct'>Oct</option>
<option value='Nov'>Nov</option>
<option value='Dec'>Dec</option>
</select>
<select name='dat'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select>
<select name='yea'>
<option value='2009'>2009</option>
<option value='2010'>2010</option>
<option value='2011'>2011</option>
</select>
<br/><br/>
<p style='margin-bottom:0;'>Type</p>
<select name='typ'>
<option value=''></option>
<option value='Maintenance'>Maintenance</option>
<option value='Meeting'>Meeting</option>
<option value='other'>other</option>
</select>
<p style='margin-bottom:0;'>Employee Id</p>
<input type='text' name='empid' /> <br/>
<p style='margin-bottom:0;'>Subject</p>
<input type='text' name='sub' /><br/>
<p style='margin-bottom:0;'>posting info</p>
<input type='text' name='tabs' /><br/>
<p style='margin-bottom:0;'>Notify E-mails</p>
<input type='text' name='ema' />
<input type='submit' />
</form>
</body>
</html>
insert.php page
Code:
<?php
include 'connection.php';
$sql="INSERT INTO postings (month,date,year,user_id,subject,table,type,email)
VALUES
('$_POST[mon]','$_POST[dat]','$_POST[yea]','$_POST[empid]','$_POST[sub]','$_POST[tabs]','$_POST[typ]','$_POST[ema]');";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
I know it looks plain and simple right now but want to get it working before i start putting the css and graphics into it.