in reply to Re: Re: (jeffa) Re: dbi insert
in thread dbi insert

The error log contains:

**************************************************
Wed Oct 17 13:46:58 2001 error client 10.1.11.104 Premature end of script headers: c:/program files/ibm http server/htdocs/um/submit2.cgi

Wed Oct 17 13:46:58 2001 error client 10.1.11.104 DBD::mysql::st execute failed: Unknown column 'firstname' in 'field list' at c:\PROGRA~1\IBMHTT~1\htdocs\um\submit2.cgi line 22.

Wed Oct 17 13:46:58 2001 error client 10.1.11.104 Database handle destroyed without explicit disconnect. *********************************************************

firstname is the value of $firstname

Replies are listed 'Best First'.
Re: Re: Re: Re: (jeffa) Re: dbi insert
by tommyw (Hermit) on Oct 17, 2001 at 16:03 UTC

    Ok, now I'm really worried. That error message is telling you quite clearly that you're attempting to access the firstname field, from the field list table. And you can't, because there's no such field in that table

    I'm worried because there are no appropriate references to such a field, table or even a variable called $firstname in your code

    Oh, hang on:

    my $sth = $dbh->prepare("INSERT into people (fornavn, efternavn, cpr, adresse, zip, city, tjenestested) values ($fornavn, $efternavn, $cpr, $adresse, $zip, $city, $tjenestested)");
    will result in the SQL statement being something along the lines of: INSERT into people(fornavn...) values (tommy, ...);. Which is, of course, incorrect: those value strings need to be quoted. You see all those earlier posts with many, many question marks in them? Well, this is exactly why they were there. Try changing your statement in a similar fashion

(jeffa) 5Re: dbi insert
by jeffa (Bishop) on Oct 17, 2001 at 19:51 UTC
    Yeah, that's not good. If tommyw's suggestion doesn't fix the problem (which i think it will), then i recommend logging directly into the mysql database server and issue the following commands:
    1. show databases - this will show you a list of the available databases, make sure 'um' is among, them - if not, then find out which database you need to use
    2. use um - assuming you found it in #1
    3. desc people; - (notice the semi-colon) this will give you a tabular text table containing the field names, their types, and more stuff about the fields.
    If you do not see 'firstname' among them - well, that's beyond the scope of this site. But i can point you to the mysql docs, in particular, the alter table syntax.

    Pertaining to your 3 errors that you listed (which should have been wrapped in <code> tags i might add), the first and third errors are most likely just side effects from the second error. Fix the second and the other two should go away as well. :)

    good luck!
    jeffa