Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Annoying sql problem ..

Status
Not open for further replies.

dbeezzz

Technical User
Nov 30, 2005
54
KR
I seem to be getting a really annoying sql problem on a very simple query
Code:
$sql = "INSERT INTO constellation ( constellation_coverletter )
					VALUES ( $val_1  )
						";
where $val_1 = 'coverletter'
It gives me
Code:
SQL Error : 1054 Unknown column 'coverletter' in 'field list'

INSERT INTO constellation ( constellation_coverletter ) VALUES ( coverletter )

Line : 43
File : my_presentation.php
... why does it tell me that the $val_1 is an 'unknown column' ? It's a value and not a col in the first place.
 
Ok I got it thanks ... I was leaving out the ' ' ... d'oh !
 
You should use $POST if you are doing and insert via a form using php.

$sql = "INSERT INTO constellation ( 'constellation_coverletter ')VALUES ( ' " .$_POST['val_1']." ' )";

 
There's no reason to think it's a $_POST or $_GET variable, but if it is you'd probably want to use mysql_real_escape_string($val_1) instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top