Now Place:2uzhan.com » MS Access :-(

MS Access :-(

PHP @ December 31, 1969   Views:0

Please can some explain to me why Im getting this error, when trying to insert into a MS Access database. (Cleary PHP love for Access, is about the same as Bush for Hussain... not much)

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4.

There is nothing wrong with the code:

PHP Code:

  $insert =  odbc_prepare($connect , "INSERT INTO fault (UserName, FaultClass, FaultLogged, DateLogged ) 
                    VALUES (\"".$formVars['UserName']."\", ". "\" ".$formVars['FaultClass']."\", "
                              ."\"". $formVars['FaultLogged']."\", " . "\" ".$time."\");");                        

Ive tried odbc_execute, odbc_do....but still same error occurs.

Thanks in advance.


i'm not sure but i think the problem is not in your query but in your connection.

i think php has not enough parameters to connect to your ODBC resource.
check where you create $connect if everything is fine.

You get error messages like that when a fieldname is incorrectly spelt. I also tried parsing your rat's nest of escaped quotes by eye but gave up.

Have you tried odbc_exec() ?

I find this a lot easier:

PHP Code:

extract ($formvars);
$insert =  odbc_exec ($connect , "INSERT INTO fault (UserName, FaultClass, FaultLogged, DateLogged ) 
                    VALUES ('$UserName', '$FaultClass', '$FaultLogged', $time)"); 

© 2018 2uzhan.com Contact