Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.