468,253 Members | 1,297 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

Unknown column 'icaodesc' in 'field list'

Greetings all.

I'm getting the following error message...

Unknown column 'icaodesc' in 'field list'

when I try to update a table from a PHP form.

What 'field list' is it referring to? My PHP script or the MySQL
table???

Here is the PHP script I'm using...

<?php

//set up table and database names
$db_name ="xxx";
$table_name ="yyy";

//connect to server and select database
$connection = @mysql_connect("localhost","user_name","password") or
die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue query
$sql ="UPDATE $table_name SET
icaodesc ='$_POST[task_icaodesc]',
icaosource ='$_POST[task_icaosource]',
icaonote ='$_POST[task_exp_outcome]',
usposition ='$_POST[task_usposition]',
expoutcome ='$_POST[task_exp_outcome]',
usposition ='$_POST[task_usposition]',
usaction ='$_POST[task_usaction]'
WHERE task_id ='$_POST[id]'";

$result = @mysql_query($sql,$connection) or die(mysql_error());
?>

icaodesc was the NAME in the updatable form. task_icaodesc is a
"good" field in the table yyy

Anyone shed any light on this mystery?

Thanks.

Ward
Aug 12 '05 #1
8 10756
On Fri, 12 Aug 2005 16:58:48 -0400, Ward B decided we needed to hear:
Greetings all.

I'm getting the following error message...

Unknown column 'icaodesc' in 'field list'

when I try to update a table from a PHP form.

What 'field list' is it referring to? My PHP script or the MySQL
table???


The MySQL table - icaodesc is evidently not a column in the table.

<snip>
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Aug 12 '05 #2
Thanks Dave.

Well, you're right. The column name is "task_icaodesc."

But is the first part of this, icaodesc ='$_POST[task_icaodesc]',
throwing off the system? icaodesc is the NAME in the update form.

<TD><strong>ICAO Description of Task:</strong><BR><textarea
name="$icaodesc" cols="30" rows="5"><? echo "$icaodesc";
?></textarea></TD>

And here is from the PHP script in the "show" page.

$icaodesc =$row['task_icaodesc'];

The show page is where the data is extracted from the db and shown in
the applicable form fields for updating.

Does this help?

In the meantime, I'll try some other combinations.

Thanks.

Ward
On Fri, 12 Aug 2005 18:12:25 +0100, Dave <da**@REMOVEbundook.com>
wrote:
On Fri, 12 Aug 2005 16:58:48 -0400, Ward B decided we needed to hear:
Greetings all.

I'm getting the following error message...

Unknown column 'icaodesc' in 'field list'

when I try to update a table from a PHP form.

What 'field list' is it referring to? My PHP script or the MySQL
table???


The MySQL table - icaodesc is evidently not a column in the table.

<snip>

Aug 12 '05 #3
Dave,

I figured it out and you gave me the motivation to try it out.

I had to change "icaodesc" to the correct column name "task_icaodesc."
I didn't think that's what was being defined here (or I can't describe
it the correct jargon). But thanks for giving me the "kick in the
head" to try it.

Now the problem is....the data isn't transferring over the the script
that does the MySQL update. Oy! It just never ends. I'm sure it's
the _$POST array something or other.

Thanks again.

Ward
On Fri, 12 Aug 2005 18:12:25 +0100, Dave <da**@REMOVEbundook.com>
wrote:
On Fri, 12 Aug 2005 16:58:48 -0400, Ward B decided we needed to hear:
Greetings all.

I'm getting the following error message...

Unknown column 'icaodesc' in 'field list'

when I try to update a table from a PHP form.

What 'field list' is it referring to? My PHP script or the MySQL
table???


The MySQL table - icaodesc is evidently not a column in the table.

<snip>

Aug 12 '05 #4
On Fri, 12 Aug 2005 18:23:37 -0400, Ward B decided we needed to hear:
Thanks Dave.

Well, you're right. The column name is "task_icaodesc."

But is the first part of this, icaodesc ='$_POST[task_icaodesc]',
throwing off the system? icaodesc is the NAME in the update form.
Your assignment in the SQL statement is the wrong way around in this
case. Your SQL statement should instead contain:

task_icaodesc = '$_POST[icaodesc]'

that assigns the value of the form variable icaodesc to the column
task_icaodesc in the database. BTW, hopefully you are validating the
value of your form variables before you update your database? - if not
you are wide open for all sorts of problems.

<TD><strong>ICAO Description of Task:</strong><BR><textarea
name="$icaodesc" cols="30" rows="5"><? echo "$icaodesc";
^^^^^^ typo? Its not a good idea for the form field name to
contain a $ sign. The field must be called icaodesc, if you are
going to refer to it in your script as $_POST[icaodesc]
?></textarea></TD>

<snip>

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Aug 13 '05 #5
"Ward B" <Wa*******@hotmail.com> kirjoitti
viestissä:t5********************************@4ax.c om...
Dave,

I figured it out and you gave me the motivation to try it out.

I had to change "icaodesc" to the correct column name "task_icaodesc."
I didn't think that's what was being defined here (or I can't describe
it the correct jargon). But thanks for giving me the "kick in the
head" to try it.

Now the problem is....the data isn't transferring over the the script
that does the MySQL update. Oy! It just never ends. I'm sure it's
the _$POST array something or other.

Vell, you can test what data has been sent to the script by dumping all of
it.
<?php
var_dump($_REQUEST);
var_dump($_GET);
var_dump($_POST);
?>

See what they contain...

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <et****************@5P4Mgmail.com>
Aug 13 '05 #6
Good afternoon Dave.

You are all correct and after some experimenting yesterday, I proved
you correct.

The textbook I was using had the $ in the name. That was throwing the
system. So I did exactly as you suggested and everything worked.

Thank you for the help.

Oh BTW, I will have validation before it goes live. <g>

Ward

On Fri, 12 Aug 2005 22:40:49 +0100, Dave <da**@REMOVEbundook.com>
wrote:
On Fri, 12 Aug 2005 18:23:37 -0400, Ward B decided we needed to hear:
Thanks Dave.

Well, you're right. The column name is "task_icaodesc."

But is the first part of this, icaodesc ='$_POST[task_icaodesc]',
throwing off the system? icaodesc is the NAME in the update form.


Your assignment in the SQL statement is the wrong way around in this
case. Your SQL statement should instead contain:

task_icaodesc = '$_POST[icaodesc]'

that assigns the value of the form variable icaodesc to the column
task_icaodesc in the database. BTW, hopefully you are validating the
value of your form variables before you update your database? - if not
you are wide open for all sorts of problems.

<TD><strong>ICAO Description of Task:</strong><BR><textarea
name="$icaodesc" cols="30" rows="5"><? echo "$icaodesc";


^^^^^^ typo? Its not a good idea for the form field name to
contain a $ sign. The field must be called icaodesc, if you are
going to refer to it in your script as $_POST[icaodesc]
?></textarea></TD>

<snip>

Aug 13 '05 #7
Well that's interesting Kimmo.

I'll try that out.

BTW, I did figure out why it isn't working...had to do with using the
$ in the NAME.

Thanks.

Ward
On Sat, 13 Aug 2005 17:11:08 +0300, "Kimmo Laine"
<et*******************@Mgmail.com> wrote:
"Ward B" <Wa*******@hotmail.com> kirjoitti
viestissä:t5********************************@4ax. com...
Dave,

I figured it out and you gave me the motivation to try it out.

I had to change "icaodesc" to the correct column name "task_icaodesc."
I didn't think that's what was being defined here (or I can't describe
it the correct jargon). But thanks for giving me the "kick in the
head" to try it.

Now the problem is....the data isn't transferring over the the script
that does the MySQL update. Oy! It just never ends. I'm sure it's
the _$POST array something or other.

Vell, you can test what data has been sent to the script by dumping all of
it.
<?php
var_dump($_REQUEST);
var_dump($_GET);
var_dump($_POST);
?>

See what they contain...

Aug 13 '05 #8
Dave wrote:
On Fri, 12 Aug 2005 18:23:37 -0400, Ward B decided we needed to hear:

Thanks Dave.

Well, you're right. The column name is "task_icaodesc."

But is the first part of this, icaodesc ='$_POST[task_icaodesc]',
throwing off the system? icaodesc is the NAME in the update form.

Your assignment in the SQL statement is the wrong way around in this
case. Your SQL statement should instead contain:

task_icaodesc = '$_POST[icaodesc]'

that assigns the value of the form variable icaodesc to the column
task_icaodesc in the database. BTW, hopefully you are validating the
value of your form variables before you update your database? - if not
you are wide open for all sorts of problems.

<TD><strong>ICAO Description of Task:</strong><BR><textarea
name="$icaodesc" cols="30" rows="5"><? echo "$icaodesc";

^^^^^^ typo? Its not a good idea for the form field name to
contain a $ sign. The field must be called icaodesc, if you are
going to refer to it in your script as $_POST[icaodesc]

?></textarea></TD>


<snip>


I think that should be:

task_icaodesc = "'" . $_POST['icaodesc'] . "'"; // or
task_icaodesc = "'{$_POST['icaodesc']}'";

The provided code will just put the characters '$_POST[icaodesc]' in the database.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 22 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ndsoumah | last post: by
2 posts views Thread by torpecool | last post: by
5 posts views Thread by Larry in Honolulu | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.