Jump to content

[SOLVED] Trouble Using Insert from PHP


buckibooster

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/143397-solved-trouble-using-insert-from-php/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.