SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL INSERT problems ...

    Hi all,

    I'm tinkering with MySQL using Chilisoft ASP for the first time. My CREATE TABLE line looked like this:

    Code:
    CREATE TABLE t_blog (f_id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (f_id), f_name CHAR, f_message TEXT, f_date DATE, f_time TIME)
    That was fine. Now, whenever I try and insert into that table using the following code I get a syntax error in my SQL string:

    Code:
    INSERT INTO t_blog (f_name, f_message, f_date, f_time) VALUES ('" & Request.Form("name") & "', '" & Request.Form("message") & "', #" & Date & "#, #" & Time & "#)
    I figure that I don't need to mention the f_id field in this string cos it's auto numbering. Am I right? I'm starting to get a sneaking suspicion that I set up my table wrong ....

    One other thing. When I write the SQL string back to the screen it looks like this:

    Code:
    INSERT INTO t_blog (f_name, f_message, f_date, f_time) VALUES ('Greg Harvey', 'Test blog entry.', #04/09/02#, # 8:31:26 #)
    Note the spaces around the time. Could this be screwing things up?

    G

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    yes, you do omit the auto increment column

    no, it's not the spaces around the times, but the hashes -- those are access formats

    use single quotes, e.g. '2002-09-04' and '15:56'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you. That works fine now!


Bookmarks

Posting Permissions

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