warning In Insert data to DB

hi
i have error when i want to insert data to Database(ms-Access)
please guide me!!

warning is :
insert into TblDarman values(ihpbpihb,’’,’’,’’,’’)
Warning: odbc_do() [function.odbc-do]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in F:Project site ExpertDarmanToseeDarman1.php on line 23

Source is:

<?php if(!strlen(trim($_GET['txt1']))) { echo "123"; die(); } $connectionstring = odbc_connect("Darman", "",""); $query ="insert into TblDarman values("; $query = $query.$_GET['txt1'].","; $query = $query."'".$_GET['txt2']."',"; $query = $query."'".$_GET['txt3']."',"; $query = $query."'".$_GET['txt4']."',"; $query = $query."'".$_GET['txt5']."')"; echo $query; $result = odbc_do($connectionstring, $query); odbc_close($connectionstring); ?>

thank u!

What did you find when trying google, or the php.net manual? What have you tried yourself in order to get around this problem, rather than try to solve it?

Your “Query” is presented as
insert into TblDarman values(ihpbpihb,’’,’’,’’,’’)
according to the error message.

One problem I see is that ihphpihb should be quoted. Obviously the other values are empty. Are those values set in the DB to allow Nulls?

Also when doing an INSERT query in that format, you MUST provide a value (or Null) for EVERY Field in the table. So by this query, there are EXACTLY 5 fields in TblDarman. Is that correct?

Finally, I presume that your CONNECT string has blanked out Password and Login because you don’t want to display it to the public here. So if that was not the case, then of course you would need to correct that.

Also with the “Connection” String, the first parameter is a DSN. So by your code, you have set up a DSN (In control Panel) for the Access database and named the DSN (Not necessarily the Database) Darman?

hi
I do your tells and corrected realation between fields in DB And PHP code but i have error yet please guid me again!!

Warning: odbc_do() [function.odbc-do]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in F:Project site ExpertDarmanToseeDarman1.php on line 25
insert into TblDarman values(hiuohi,‘hiph’,‘piuh’,‘poiuh’,‘poiuh’,‘piuh’,‘poiu’)

How Can I Solve This Problem?

Sponsor our Newsletter | Privacy Policy | Terms of Service