contraboybish Posted May 12, 2007 Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/ Share on other sites More sharing options...
Barand Posted May 12, 2007 Share Posted May 12, 2007 Works better when the query is executed $query = "DELETE FROM subscription WHERE subId = '{$_POST['id']}'" odbc_exec($query) or die (odbc_errormsg()); Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251198 Share on other sites More sharing options...
contraboybish Posted May 12, 2007 Author Share Posted May 12, 2007 ok have just tried your script, to the letter and now i get..... Parse error: syntax error, unexpected T_STRING in D:\bishserver\library\register_delete.php on line 7 Any thoughts :-/ Bish Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251283 Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 Paste the code please? Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251286 Share on other sites More sharing options...
Barand Posted May 12, 2007 Share Posted May 12, 2007 Missed ; at end of first line. Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251287 Share on other sites More sharing options...
contraboybish Posted May 12, 2007 Author Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251293 Share on other sites More sharing options...
paul2463 Posted May 12, 2007 Share Posted May 12, 2007 try $query = "DELETE FROM subscription WHERE subId = '{$_POST['id']}'" odbc_exec($odbc,$query) or die (odbc_errormsg()); Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251297 Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 <?php odbc_exec($odbc, $query); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251298 Share on other sites More sharing options...
Barand Posted May 12, 2007 Share Posted May 12, 2007 Ah, odbc queries need the connection specifying 8: odbc_exec($conn, $query) or die (odbc_errormsg()); where $conn was the value returned by odbc_connect Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251299 Share on other sites More sharing options...
contraboybish Posted May 12, 2007 Author Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251306 Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 Don't use $conn, use $obdc. Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251307 Share on other sites More sharing options...
Barand Posted May 12, 2007 Share Posted May 12, 2007 Call it $aspidistra if you want, so long as it's the value returned when you connected, Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251308 Share on other sites More sharing options...
contraboybish Posted May 12, 2007 Author Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251310 Share on other sites More sharing options...
Barand Posted May 12, 2007 Share Posted May 12, 2007 try removing quotes if id is numeric $query = "DELETE FROM subscription WHERE subId = {$_POST['id']} "; Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251312 Share on other sites More sharing options...
contraboybish Posted May 12, 2007 Author Share Posted May 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51038-solved-how-do-you-delete-entries-from-odbc-using-php/#findComment-251315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.