php sql insert error - stumped!

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

    php sql insert error - stumped!

    ok - I have no idea what's doing on. In a nutshell I am doing a SQL
    insert in a Access database from PHP but am getting an error.

    Here is the code:

    // PHP db connection
    $db = 'C:\\Phpweb\\go vDB.mdb';
    $conn = new COM('ADODB.Conn ection');
    $conn->Open("Provider =Microsoft.Jet. OLEDB.4.0; Data Source=$db");

    and here is the error:

    Warning: (null)(): Invoke() failed: Exception occurred. Source:
    Microsoft JET Database Engine Description: Syntax error in INSERT INTO
    statement. in c:\phpweb\detai lcard.php on line 198

    and here is a print out of the sql:
    INSERT INTO Cards(active,co mpanynam,divisi on,streetnumb,s treet,town_city ,province,filet itle,air,water, sewage,pttw,par tVIII,part46,mi scellany,grr,gr rfile)
    VALUES ('0','1 HOUR PHOTO PLUS','ob','24' ,'RAMBLER
    DRIVE','BRAMPTO N','Ontario','S I HP BR RA','0','0','0' ,'0','0','0','R EG
    347 - 1592500','15925 00','700')

    the sql works if I do a query in Access.....

    please help me out...I'm losing my mind!

    Thanks!
  • Kafooey

    #2
    Re: php sql insert error - stumped!

    On 12 Nov 2003 19:19:29 -0800, mpaterso@uoguel ph.ca (MP) wrote:
    [color=blue]
    >and here is a print out of the sql:
    >INSERT INTO Cards(active,co mpanynam,divisi on,streetnumb,s treet,town_city ,province,filet itle,air,water, sewage,pttw,par tVIII,part46,mi scellany,grr,gr rfile)
    >VALUES ('0','1 HOUR PHOTO PLUS','ob','24' ,'RAMBLER
    >DRIVE','BRAMPT ON','Ontario',' SI HP BR RA','0','0','0' ,'0','0','0','R EG
    >347 - 1592500','15925 00','700')[/color]

    Access is notoriously lenient. I don't want to cause havoc, but your
    field names should really all be prepended with an indicator to the
    data type (e.g. nField for numeric, cField for char/varchar). It's
    just a good practice to get into.

    It looks like you are setting all field values to string/character
    data... are none of the fields numeric at all? Access will probably
    let you get away with setting a number to a string value, but I'm
    betting PHP won't.

    Comment

    • MP

      #3
      Re: php sql insert error - stumped!

      ok thanks I'll check that out...as per the names is a government
      database so I can't change it...I gotta work with what I'm given :)

      Thanks


      Kafooey <kafooey@yahoo. co.uk> wrote in message news:<fb27rv8l5 nqau4dfmuos6sat cj9s4anhsc@4ax. com>...[color=blue]
      > On 12 Nov 2003 19:19:29 -0800, mpaterso@uoguel ph.ca (MP) wrote:
      >[color=green]
      > >and here is a print out of the sql:
      > >INSERT INTO Cards(active,co mpanynam,divisi on,streetnumb,s treet,town_city ,province,filet itle,air,water, sewage,pttw,par tVIII,part46,mi scellany,grr,gr rfile)
      > >VALUES ('0','1 HOUR PHOTO PLUS','ob','24' ,'RAMBLER
      > >DRIVE','BRAMPT ON','Ontario',' SI HP BR RA','0','0','0' ,'0','0','0','R EG
      > >347 - 1592500','15925 00','700')[/color]
      >
      > Access is notoriously lenient. I don't want to cause havoc, but your
      > field names should really all be prepended with an indicator to the
      > data type (e.g. nField for numeric, cField for char/varchar). It's
      > just a good practice to get into.
      >
      > It looks like you are setting all field values to string/character
      > data... are none of the fields numeric at all? Access will probably
      > let you get away with setting a number to a string value, but I'm
      > betting PHP won't.[/color]

      Comment

      Working...