#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Guayquil, Ecuador
    Posts
    7
    Rep Power
    0
    I am afraid this is a beginners question, but i hope you give a little help with this.
    I want to insert values in a table trough ODBC, here is the code:
    $result = odbc_exec($db,"INSERT INTO TABLE (COL1, COL2, COL3, COL4, COL5, COL6) VALUES ($col1, $col2, $col3, $col4, $col5, $col6)");

    well, after the sentence $result is not zero, it means that it was well interpreted,
    but values were not inserted into table, why?, what should i do?, please help me...
    Otto
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    43
    Rep Power
    15
    I think you might need single quotes around your variables if they're CHARACTER STRINGS but not if they are INTEGERS or FLOATS:

    "INSERT INTO table (col1, col2, col3) VALUES ('$col1', '$col2', '$col3')"

    I think DATES may also require single quotes.
    Some machines require double quotes if ANSI mode isn't enabled.
    Good Luck


    ------------------
    webpatron.com
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Guayquil, Ecuador
    Posts
    7
    Rep Power
    0
    Thanks a lot, but it didnt work, with or without quotes, any oyher ideas?
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Try it a couple at a time - if there is an error in the format of any of the $col variables its easy to find out which ones this way.

    $sql="INSERT INTO TABLE (COL1, COL2) VALUES ('$col1', '$col2')";
    $res = odbc_exec($db,$sql);


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

Similar Threads

  1. Replies: 4
    Last Post: February 8th, 2004, 11:07 PM
  2. Inserting from form to multiple tables
    By barth in forum MySQL Help
    Replies: 0
    Last Post: January 25th, 2004, 09:27 AM
  3. display data from two tables using drop down box
    By skootz in forum PHP Development
    Replies: 9
    Last Post: January 23rd, 2004, 08:55 AM
  4. my comp sux lately , need help from pro's
    By Hykinsel007 in forum Windows Help
    Replies: 2
    Last Post: January 5th, 2004, 01:52 PM
  5. adding data to 2 tables at the same time
    By bulletz in forum ASP Programming
    Replies: 1
    Last Post: December 29th, 2003, 12:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo