Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Hardware Issue'. in C:\Inetpub\wwwroot\Mouse Tracks\Interface\index.php on line 207

I haven't a clue as too what it is talking about. Please help me

$conn->Execute("INSERT INTO Event (EventUserID,EventType,EventPriority,EventDueDate,EventDesc) VALUES ($user,$POST[FormEventType],$POST[FormEventPriority],$POST[FormDueDate],$POST[textarea2])");

btw when i use $_POST['anything']; I get an undefined variable notice. So I removed the ''.

thanks in advance

    try to echo your query instead of executing it.
    you'll be able to see if the problems come from your query or from your connection to the database.

    now using $_POST['anything'] should work.
    are you sure your from submit in post and not get ?

      I don't know whats wrong with my code. it says its an query error. But the function syntax and everything looks right. Mabye its because of the ' '. But if i take them out it will give me errors.

        i agree with the above - echo out your SQL statement to check it before executing it.

        And also i'd reiterate the question of GET variables - are you sure your form is posting to this page?

          I am dazed and confused. What do you mean echo it out. Could you please provide example(s)?

          thanks
          After I echo it..

          Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4. in C:\Inetpub\wwwroot\Mouse Tracks\Interface\index.php on line 209

            change it to :

            $sql = "INSERT INTO Event (EventUserID,EventType,EventPriority,EventDueDate,
            EventDesc) VALUES ($user,$_POST[FormEventType],$_POST[FormEventPrior
            ity],$_POST[FormDueDate],$_POST[textarea2])"; 
            echo $sql;
            $conn->Execute($sql);
            

            hence, echo-ing it out so you can see what it's doing. I'll bet it wont be doing much without the ' in your $_POST variables.

            it also looks to me that the problem is actually in your ODBC connection settings, which presumably have happened before this even gets executed.

              I don't think the database likes the way the values are being passed to it (datatype?). aslo In my php book it gives me examples of values being passed with quotes, But How would I do this with variables. Should I try casting them using String(variable);

              Btw.. I am with stupid😕

                I don't think the database likes the way the values are being passed to it (datatype?). aslo In my php book it gives me examples of values being passed with quotes, But How would I do this with variables. Should I try casting them using String(variable);

                Btw.. I am with stupid😕

                  To get the single quotes to work use the curly brackets:

                  $sql="INSERT ..... {$_POST['varname']}, ....";

                  The curly brackets tell PHP to evaluate EVERYTHING between the curly brackets as a PHP expression. (Remember you are in an evaluated string (terminated in double quotes). What php is doing without the curly brackets is trying to evaluate $_POST[, and nothing else because the single quote is normally a string delimiter.

                    Write a Reply...