473,574 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete accounts not working

57 New Member
I have the following code in my website and it is supposed to delete a user account along with all associated records, however it doesn't delete any of the records, the function is working, beacuse I also have a logout function that gets called afterwards that is working, it just seems to be skipping the delete commands.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. function delacc(){
  2.       $retrievedusr = $_COOKIE['usrid'];
  3.       $dsql1 = "DELETE FROM mpw_3_5_test_dbase_users WHERE username = $retrievedusr";
  4.       $dresult1 = mysql_query($dsql1);
  5.       $dsql2 = "DELETE FROM mpw_3_5_test_dbase_usc WHERE username = $retrievedusr";
  6.       $dresult2 = mysql_query($dsql2);
  7.       $dsql3 = "DELETE FROM mpw_3_5_test_dbase_notes WHERE username = $retrievedusr";
  8.       $dresult3 = mysql_query($dsql3);
  9.       logout();
  10.     }
P.S. I can't provide a link to the website as it isn't online yet.
Oct 25 '09 #1
4 1680
6,050 Recognized Expert Expert
You should be checking whether your queries executed successfully.

Expand|Select|Wrap|Line Numbers
  1. $query = mysql_query("SELECT * FROM `tbl`;");
  2. if (!$query) {
  3.     printf("Query failed: %s", mysql_error());
  4. }
Oct 25 '09 #2
16 New Member
You might want to use more quotes. I think that's the problem here since an username is most likely a string with letters and/or numbers. Mysql doesn't "like" that.

Try this:
Expand|Select|Wrap|Line Numbers
  1. $dsql1 = mysql_query("DELETE FROM mpw_3_5_test_dbase_users WHERE username='".$retrievedusr."'");
Oct 29 '09 #3
1,168 Recognized Expert Top Contributor
You don't actually need to separate the string if it's a " string as opposed to a ' string:
Expand|Select|Wrap|Line Numbers
  1. $dsql1 = mysql_query("DELETE FROM mpw_3_5_test_dbase_users WHERE username='$retrievedusr' LIMIT 1");
I also suggest using LIMIT so your queries stop searching once they find one (as I imagine you usernames are unique).
Oct 29 '09 #4
57 New Member
Hi guys, sorry for the late reply, it is working perfectly now, thank you for all of your help.
Nov 10 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: de Beers | last post by:
mysql_query("DELETE FROM cart WHERE ItemId=$ItemId"); There is the code but the result in my databse is that the ID number changes from, lets say, 77 to 78 with 78's contents being empty. Therefore when I look at the results - the deleted ID77 is gone but now I have ID78 with no content! Does anyone know why and how do I make it stop? ...
by: Ted Ward | last post by:
Hi all. I have MySQL 4.0.18 and phpMyAdmin running on a FreeBSD box. The other day a student told me he logged on to my phpMyAdmin by specifying "guest" as the user and no password. I don't have a guest user in my user table and can't seem to find any documentation on how to disable this. It makes me a little nervous. Ted
by: HankD | last post by:
We have a particularly strange problem. We are running Two clustered Windows 2003 boxes running IIS 6. Our ASP.NET application run fine but over night they stop working. The error we get is: File or assembly name 0x3yhs89.dll, or one of its dependencies, was not found. We tracked the problem to the ASPNET worker processes (NETWORK...
by: krock_112 | last post by:
I'm trying to set up a group of shared folders. Folder 1 Folder 2 Common Share I want all users that have access to folder 2 to be able to create new folders, add documents to the sub folders, pretty much do everything but delete. I have been unsuccesful so far. I either have to give everyone complete access which then gives them the...
by: LostBoy | last post by:
Hello, I have created a subform/report on a form based on a table. I would like to be able to delete the accounts if necessary. I thought creating a delete button using the wizard would work but it did not. I tried ‘RunCommand acCmdDeleteRecord’ but that did not work either. I know if I right click on the account and then delete works but I am...
by: =?Utf-8?B?SnVsaWE=?= | last post by:
i cannot delete some user accounts on my laptop. i am the computer administrator and these accounts im trying to delete are limited accounts. i select delete account in the user accounts and it asks if i want to delete or keep files. i select delete files and then confirm the deletion of the account. it will sit there for a minute and then...
by: rbukkara | last post by:
Hi guys, I have some trouble with the following query. Please look into this and lemme know the solution ASAP. It certainly involves aggregations and the 'having clause' BROKER( ID integer primary key , NAME string)
by: shapper | last post by:
Hello, I am working on an ASP.NET which sends newsletters and other e emails to clients. Which emails accounts do you usually use on your web sites for application to use: gateway@mydomain.com, noreply@mydomain.com, ... ? Is there a standard or a better way to call this email accounts ...
by: KingKong07 | last post by:
Hi I need some help on a query. I need to delete some records from a table, this table has a dependency to another table Table 1: dbo.Accounts and Table 2: dbo.AccountsToUser In the dbo.Accounts table there are AccountId and OwnedByAccountId
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.