Jump to content
Larry Ullman's Book Forums

Sql Insert Strings Into A Database


Recommended Posts

Hiya,

 

I have created the following field in a form.

Track or Pole? TrackPole

 

As you can see the values are strings. I have then assigned these values to a variable in a session.

 

I am now trying to insert this value into a database and have received the following error:

 

An error has occurred in script 'C:\xampp\htdocs\Dis Soft Furnishings\web\confirm_save.php' on line 56: Query: INSERT INTO saved_curtains (user_id, fabric_drop, track_pole, track_pole_width, heading_tape, lining, fullness, interlined, fabric_width, final_curtain_quote, saved_date) VALUES (6, 100, track, 100, three, regular, 2, no, 139, 56.20, NOW() )

MySQL Error: Unknown column 'track' in 'field list'

Date/Time: 6-5-2012 13:54:52

. print_r(Array, 1) .

 

I then changed the values of 'track' and 'pole' to '1' and '2' and the error changed to exactly the same except:

 

MySQL Error: Unknown column 'three' in 'field list'

 

This proves to me that the problem lies in the fact that it doesn't like the string as opposed to a number and that the error just moved 'along' to the next string.

 

I understand that in SQL strings need to be quoted but how do I quote: {$curtain_list['track_pole']}, which is the extract from the INSERT command? I have tried changing the quotes in the original HTML form and also various ways on the INSERT command but doesn't seem to work.

 

Cheers

Paul

Link to comment
Share on other sites

The above HTML has not shown correctly, it should be:

 

<p>Track or Pole? Track<input name="track_pole" type="radio" value="track" checked="checked" />Pole<input name="track_pole" type="radio" value="pole" /></p>

 

Sorry.

Paul

Link to comment
Share on other sites

INSERT command with values like : {$curtain_list['track_pole']}

INSERT INTO ................ VALUES ( '{$curtain_list['track_pole']}', ) //quote outside curly bracket

 

Hope that's what the problem is about....

  • Upvote 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...