buckibooster Posted February 1, 2009 Share Posted February 1, 2009 I am new to the use of mySQL. I have created a html form that passes data to a php script that is supposed to create a connection to my database and input a single set of data. I know that it is making the connection and even getting my posted data echoed but keep getting an error for the INSERT query. Here are the relevant lines of php code: $query = "INSERT INTO TomsList ( Date, IP_Address, Show, Type, User, EMail, Phone, Division, Location, Title, Description, File1) VALUES ( '$_POST[todaysDate]', '$_POST[ipAddress]', '$_POST[showOrHide]', '$_POST[dbType]', '$_POST[Name]', '$_POST', '$_POST[Phone]', '$_POST[Division]', '$_POST[Location]', '$_POST[Title]', '$_POST[Description]', '$_POST[file1Name]')"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query!"); Can anyone tell me what I am doing wrong? Any help you can give me will be very much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/143397-solved-trouble-using-insert-from-php/ Share on other sites More sharing options...
trq Posted February 1, 2009 Share Posted February 1, 2009 The word Show is a reserved word in mysql. You should rename your field to something else. Also note that inserting data straight from a form like that poses a security risk. You need to escape all user input using mysql_real_escape_string before placing it in any query. Quote Link to comment https://forums.phpfreaks.com/topic/143397-solved-trouble-using-insert-from-php/#findComment-752177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.