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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.