auto value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BjoernJackschina

    #1

    auto value

    Hello,
    just a small problem. Can't insert a dataset when I use following
    example with an auto value in table answer(failing which it works):
    {
    $sql=sprintf("I NSERT INTO answer VALUES(\"%s\",\ "%s\",\"%s\ ")",
    addslashes($mov e), addslashes($val ue), addslashes($wis h));

    $result = mysql_query($sq l,$db_link);

    if(!$result)
    {
    echo mysql_error($db _link);
    }
    }
    what's wrong?
    what about trigger or view in MySQL in next future?

    Thank you
  • Bill Karwin

    #2
    Re: auto value

    BjoernJackschin a wrote:
    [color=blue]
    > Hello,
    > just a small problem. Can't insert a dataset when I use following
    > example with an auto value in table answer(failing which it works):
    > {
    > $sql=sprintf("I NSERT INTO answer VALUES(\"%s\",\ "%s\",\"%s\ ")",[/color]

    Explicitly name the columns you're inserting into, and omit the column
    that is defined as auto-increment. In other words, if your table is as
    follows:

    CREATE TABLE answer (
    id integer NOT NULL AUTO_INCREMENT PRIMARY KEY
    field2 varchar(20),
    field3 varchar(20),
    field4 varchar(20)
    )

    Insert data into it as follows:

    INSERT INTO answer (field2, field3, field4) VALUES (..., ..., ...)
    [color=blue]
    > what about trigger or view in MySQL in next future?[/color]

    Triggers are supposed to be available in MySQL 5.0.2.
    Views are supposed to be available in MySQL 5.0.1.
    MySQL 5.0.2 is available in alpha status.
    http://dev.mysql.com/doc/mysql/en/Roadmap.html

    Regards,
    Bill K.

    Comment

    Working...