Re: Updating Tables
| From: | Doug Semig | Date: | Sat, 04 Nov 2000 08:09:41 +0000 |
| Subject: | Re: Updating Tables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4208@lists.php.net to get a copy of this message | ||
Just some guesses...
Perhaps in the associated HTML form, the user entered in a value that
contained a character that has special meaning to your database backend? I
notice that you aren't using addbackslashes.
Or perhaps the user didn't fill in one or more of the fields? Most
databases will gripe about "INSERT INTO table (field) VALUES ('')".
Or perhaps your "WORDS" table isn't spelled exactly like that (for example,
it's a "WORD" table) or it is spelled with some or all lowercase letters
(for example, "words") in the db and your dbms correctly uses case
sensitive identifiers? Same casing idea applies to the list of field names
in the SQL statement.
But no matter what, you may want to find and read some documentation on
bringing your database schema into at least 3rd normal form. There are
many advantages and few disadvantages to designing your database well right
from the beginning. There are several things that really stand out: the
spellingX columns, the who_submit and email_contact columns, and the
definition_source column are all obvious candidates for normalization.
Doug
t 08:36 PM 11/3/00 -0500, Luo, Mark wrote:
>hi everyone:
>this code didn't insert to the database table
>
> $confirm_hash = substr(md5($session_hash . $HTTP_POST_VARS[spelling2] .
>time()),0,16);
>// $confirm_hash = confirm_hash
>
> $GLOBALS[newWordID] = db_insertid(db_query(
> "INSERT INTO WORDS
>(word,spelling1,spelling2,definition,email,Cdate,status,who_submit) "
> . "VALUES
>('$HTTP_POST_VARS[word]','$HTTP_POST_VARS[spelling1]',"
> .
>"'$HTTP_POST_VARS[spelling2]','$HTTP_POST_VARS[definition]',"
> . "'$HTTP_POST_VARS[form_email]','" . time() .
> ",'P','" //
>status
> . $confirm_hash
> . "'"
> . ")"));
>
>
>the table discription is
>
>+---------------------------+--------------+------+-----+---------+---------
>-------+
>| Field | Type | Null | Key | Default | Extra
>|
>+---------------------------+--------------+------+-----+---------+---------
>-------+
>| a | int(11) | | PRI | 0 |
>auto_increment |
>| word | varchar(50) | | | |
>|
>| spelling1 | varchar(50) | YES | | NULL |
>|
>| spelling2 | varchar(50) | YES | | NULL |
>|
>| spelling3 | varchar(50) | YES | | NULL |
>|
>| spelling4 | varchar(50) | YES | | NULL |
>|
>| definition | mediumtext | | | NULL |
>|
>| who_submit | varchar(70) | | | |
>|
>| Cdate | int(11) | | | 0 |
>|
>| email_contact | varchar(90) | | | |
>|
>| last_date_of_modification | date | YES | | NULL |
>|
>| definition_source | varchar(150) | YES | | NULL |
>|
>| status | char(1) | YES | | NULL |
>|
>+---------------------------+--------------+------+-----+---------+---------
>-------+