Mancent Posted November 9, 2012 Share Posted November 9, 2012 I can not delete from where id = id. becasue that would delete all of them, I want to delete from table where id and name and fid == the same how would i do that can i do this with the delete DELETE FROM tablename WHERE id = ('$id') AND name =('$name') AND fid =('$fid') Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/ Share on other sites More sharing options...
MDCode Posted November 9, 2012 Share Posted November 9, 2012 (edited) DELETE FROM tablename WHERE id = ('$id') AND name =('$name') AND fid =('$fid') Yes you can, the parentheses serve no purpose though Edited November 9, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391374 Share on other sites More sharing options...
Mancent Posted November 9, 2012 Author Share Posted November 9, 2012 so would that only delete where the id = 1029384 and the name = some name and the fid = 2938575? and not delete all the id = 1029384 kinda like a select system inside the delete. Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391376 Share on other sites More sharing options...
MDCode Posted November 9, 2012 Share Posted November 9, 2012 Yes Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391377 Share on other sites More sharing options...
Mancent Posted November 9, 2012 Author Share Posted November 9, 2012 awesome cool. thank you. never tested it yet not that far i just wondered. Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391378 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 For some reason its not deleting the data, been tracing it all out and the post being send is all correct. is my syntax wrong $Delete = mysql_query("DELETE FROM WiiS_Shared_Music WHERE UserId='$MyUserId' AND UserFId='$FbUserId' AND SongName='$SongName' AND SongUrl='$SongUrl'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391414 Share on other sites More sharing options...
MDCode Posted November 10, 2012 Share Posted November 10, 2012 If there are no errors then there are no results that match your query Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391415 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 mysql table WiiS_Shared_Music 100002957030150 Three Days Grace - Home http://wiistream.com/users/100001957015772/sounds/028d18dfa174315ef5dca7c006b815fd.wss 100001957015772 1 1 Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391417 Share on other sites More sharing options...
MDCode Posted November 10, 2012 Share Posted November 10, 2012 (edited) Remove or die(mysql_error()); as well as the mysql_query() to leave only your query: $Delete = "DELETE FROM WiiS_Shared_Music WHERE UserId='$MyUserId' AND UserFId='$FbUserId' AND SongName='$SongName' AND SongUrl='$SongUrl'" Under that add echo $Delete; to show what you're looking for in the query Edited November 10, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391419 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 (edited) UserId='$FbUserId' I had it backwards UserFId='$MyUserId' it works now Edited November 10, 2012 by Mancent Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391420 Share on other sites More sharing options...
MDCode Posted November 10, 2012 Share Posted November 10, 2012 So it's solved? Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391421 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 yes. Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391423 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 yes for now, but the bad thing about this is its so unsecure if anyone knew the userid and the friend id and the song name song url they could delete any song from any user with out adding a join table that had a accesstoken, so it still needs more work, but the basic there. Quote Link to comment https://forums.phpfreaks.com/topic/270518-delete-from-mysql-database-help/#findComment-1391426 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.