473,699 Members | 2,715 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 1687
Markus
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. }
  5.  
Oct 25 '09 #2
didoamylee
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
TheServant
1,168 Recognized Expert Top Contributor
@didoamylee
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
wangers16
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

20
3916
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? MIchael
2
5289
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
0
821
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 SERVICES
3
1890
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 delete option, or I give them read only which takes away their modify ability.
2
1931
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 trying to avoid using that method. Is it possible to delete individual records in a subform/report...
1
1588
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 say "not responding". i have deleted accounts before, and for some reason it just freezes and...
3
1578
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)
1
1185
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 ...
2
13215
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
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4374
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.