Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    New York, NY
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Entering new row, using PHP

    I'm trying to add a row to a MySQL database using PHP. I keep getting an error though.

    Here is the line of code...

    insert into advisoryarticles values ("", $article_date, $article_title, $article_url, $bioid, $article_source);

    The first field is an auto_incremental field, so I am trying to leave it blank and let the database choose. Is that where the problem lies?


    Jabbamonkey

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    North East England
    Posts
    853
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You don't need to leave that blank when auto_increment is specified...

    Try this (I'm assuming you have the field names the same as the variable names, right?):

    Code:
    INSERT INTO advisoryarticles(article_date,article_title,article_url,bioid,article_source) VALUES('$article_date','$article_title','$article_url','$bioid','$article_source');
    Dunno, why it's being truncated btw
    [+] Computer/PC issues [+] Silverpaw3D
    ------------------------------------------------
    Never buy a dwarf with learning disabilities...

    ...it's not big, and it's not clever.

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    New York, NY
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Got it.

    Silly me. What I had would have worked....

    I'm using a PHP book to learn this stuff, and the book overlooked a simple and important aspect...

    PUT ALL THE ABOVE INTO A mysql_query...
    mysql_query(" ",$db);

    Ug...

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Jabbamonkey,

    If you are going to ask mysql related questions you need to post them in the mysql forum.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    New Coder
    Join Date
    Aug 2002
    Location
    New York, NY
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...
    Last edited by Jabbamonkey; 08-16-2002 at 03:09 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •