Jump to content

[SOLVED] How do you delete entries from ODBC using php


contraboybish

Recommended Posts

Ok i have an Access Database that i can read and write to no problems

however, when i try to delete an entry it all seems to run with no

error but the record never deletes!!!!!  The '$_POST[id]' is from a previous page.

 

this is the code i am using.............

 

<?php

require_once('testconnection.php');

 

$query = ("DELETE FROM subscription WHERE subId = '$_POST[id]'") or die (odbc_errormsg());

 

odbc_close($odbc);

header("Location: register_results.php");

?>

 

 

Am i missing something???

 

Please help i'm almost out of frustration tablets :-)

 

Bish

This is the code i have now......

 

7:    $query = "DELETE FROM subscription WHERE subId = '{$_POST['id']}'";

8:    odbc_exec($query) or die (odbc_errormsg());

 

The error message now is.....

 

Warning: Wrong parameter count for odbc_exec() in D:\bishserver\library\register_delete.php on line 8

 

Where's it going wrong!!!

 

Bish

 

Ok Here is the code now...

 

$query = "DELETE FROM subscription WHERE subId = '{$_POST['id']}'";

odbc_exec($conn, $query) or die (odbc_errormsg());

 

odbc_close($odbc);

 

ok tried the above and i now get....

Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in D:\bishserver\library\register_delete.php on line 8

 

When i add a subscription the code i use is as follows and it works fine...

 

$query = odbc_exec($odbc, "INSERT INTO subscription (subName, subTitle, subAddress, subTelephone, subEmail, subDate)

VALUES('$_POST[name]','$_POST[title]','$_POST[address]','$_POST[telephone]','$_POST[emailaddress]', now())") or die (odbc_errormsg());

 

AAaaaarrrgghh

Looking at all the above and putting it all together.....

 

<?php

 

require_once('testconnection.php');

 

$query = "DELETE FROM subscription WHERE subId = '{$_POST['id']}'";

odbc_exec($odbc, $query) or die (odbc_errormsg());

 

odbc_close($odbc);

 

header("Location: register_results.php");

 

?>

 

I now get a serious looking error message.......

 

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect in D:\bishserver\library\register_delete.php on line 6

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

 

I can see me downloading the MDB file from the server deleting the files and uploading it again!! Didn't think this was going to be this difficult!!! :-)

 

Bish

Thats it brilliant it works!!!!!

Final code is............

 

<?php

 

require_once('testconnection.php');

 

$query = "DELETE FROM subscription WHERE subId = {$_POST['id']}";

odbc_exec($odbc, $query) or die (odbc_errormsg());

 

odbc_close($odbc);

 

header("Location: register_results.php");

 

?>

 

I have to say this is the first time i have used a forum and you guys

have been brilliant.

 

Many many thanks

 

Bish

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.