SQL Insert - Weird Error

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

    SQL Insert - Weird Error

    Ok - has anyone ever had this happen before?

    I have a SQL Insert statement. When I build the SQL and execute it in PHP I
    get the following error:

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

    So then I echo the SQL statement and this is what it looks like:
    INSERT INTO
    Cards(active,di vision,province ,filetitle,air, water,sewage,pt tw,partVIII,par t
    46) VALUES ('1','ob','Onta rio','0 0 0 0','0','0','0', '0','0','0')

    Everything is formatted correctly - column names format ect.

    So then I take the echo'd sql and copy it into the PHP code as the sql
    statement. When I re-run the SQL code with static sql statement it inserts
    the record!!!!!

    So basically if I build the SQL dynamically it won't execute. But if I echo
    the dynamic sql then copy it into a sql variable it executes!

    This is driving me nuts....please help!

    Thanks,
    Matt


  • Erwin Moller

    #2
    Re: SQL Insert - Weird Error

    Hi Matt,

    I once had the same problem with JET (ACCESS)

    The reason was I used a RESERVED WORD for columnname. *sigh*
    Is it possible you do the same?
    Maybe active is reserved, I am not sure though..

    You could check by giving all your coloumnnames an extra XXX on the end and
    retry.

    Good luck,
    Erwin Moller

    Comment

    Working...