BRYANBRYAN Posted April 15, 2013 Share Posted April 15, 2013 ok i created this to add a user to follow list if(Params::getParam('follow')!='') { if(osc_logged_user_id()!='') { $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('follow'), osc_logged_user_id()); if(!isset($fav['fk_i_user_id'])) { $conn->osc_dbExec("INSERT INTO %st_follow (`fk_i_user_id`, `fk_i_seller_id`) VALUES (%d, %d)", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('follow')); } } } now i need something to remove user from same list, im new to php and mysql so i tried something like this but it doesnt work if(Params::getParam('unfollow')!='') { if(osc_logged_user_id()!='') { if(!isset($fav['fk_i_user_id'])) { $conn->osc_dbExec("DELETE FROM %st_follow fk_i_user_id = %d AND fk_i_seller_id = %d LIMIT 1", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow')); } } } can someone please help me make it work, thank you so much. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 15, 2013 Share Posted April 15, 2013 DELETE ... WHERE ... Just as in as SELECT query Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 15, 2013 Author Share Posted April 15, 2013 it worked, thanks so much Barand, i cant believe i was 1 word away. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) im sorry to bother u but it worked only once, i even removed LIMIT 1 and it wont work any more, hmm? if(Params::getParam('unfollow')!='') { if(osc_logged_user_id()!='') { $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('unfollow'), osc_logged_user_id()); if(!isset($fav['fk_i_user_id'])) { $conn->osc_dbExec("DELETE FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow')); } } } Edited April 15, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
Barand Posted April 15, 2013 Share Posted April 15, 2013 Define "doesn't work" Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) like i said im very new to this especially mySQL am i getting close to right ? if(Params::getParam('unfollow')!='') { $conn->osc_dbExec("DELETE FROM %st_follow WHERE fk_i_item_id = %d AND fk_i_user_id = %d LIMIT 1", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('unfollow')); } Edited April 15, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 15, 2013 Author Share Posted April 15, 2013 wtf type it right already lol Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 16, 2013 Author Share Posted April 16, 2013 can someone please type this as it should be, thank you Quote Link to comment Share on other sites More sharing options...
Barand Posted April 16, 2013 Share Posted April 16, 2013 Your query syntax looks fine. You need to provide it with three values to substitute for the %s, %d %d. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 16, 2013 Author Share Posted April 16, 2013 (edited) ok can u show me how and wright it, because i cant delete simple db entry with this what i wrote Edited April 16, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
Barand Posted April 16, 2013 Share Posted April 16, 2013 I've done all I can. The inner workings of your classes is down to you. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 16, 2013 Author Share Posted April 16, 2013 huh? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 16, 2013 Share Posted April 16, 2013 All I can see is that you are passing 4 arguments to to a class method called osc_dbExec. You are not reporting any errors so I assume it expects and takes those four without any problems. But, not being clairvoyant, I don't know what that method then does with them. As I said, your class. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 16, 2013 Author Share Posted April 16, 2013 (edited) ok once again when i code if(Params::getParam('follow')!='') { if(osc_logged_user_id()!='') { $fav = $conn->osc_dbFetchResult("SELECT * FROM %st_follow WHERE fk_i_seller_id = %d AND fk_i_user_id = %d", DB_TABLE_PREFIX, Params::getParam('follow'), osc_logged_user_id()); if(!isset($fav['fk_i_user_id'])) { $conn->osc_dbExec("INSERT INTO %st_follow (`fk_i_user_id`, `fk_i_seller_id`) VALUES (%d, %d)", DB_TABLE_PREFIX, osc_logged_user_id(), Params::getParam('follow')); } } } when it receives follow it inserts date into database, now i wanted to do delete that same data when it receives unfollow, if u were me what would u wright to remove date u just imputed with this code. im sorry if i sound stupid but im a newbie Edited April 16, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 17, 2013 Author Share Posted April 17, 2013 (edited) since Barand wasnt able to figure this one out, any other gurus that know what they are doing that can simply post the right code to unfollow or delete data from database following my pattern of adding it, thanks in advance. Edited April 17, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 17, 2013 Share Posted April 17, 2013 Yeah no. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 17, 2013 Author Share Posted April 17, 2013 why are people on this site not helping, am i doing something wrong? Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 17, 2013 Share Posted April 17, 2013 simply post the right code to unfollow or delete data from database following my pattern of adding it We don't respond well to this type of demanding entitled language. We also can't help you if you don't post the relevant code. Barand asked you to. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 17, 2013 Author Share Posted April 17, 2013 (edited) i wasnt demanding just asking for him to stop pulling me around and acting like a wizard of oz to a total noob, i have no idea what he is asking, this is all the code i have to add entry to a table and it works someone that knows php can figure out the reverse code for it to delete entry from db and code it for me since i already said im stupid for php. im sorry if i sounded demanding but not to get any code written by you gurus in 3 days wasnt expected he is doing it like this, you ask him can u show me how to make pizza, he goes are u using flour in your dough, u say here im using water flour and salt, he goes is your pepperoni beef or chicken, just lay it on pizza, u r like but how do i make pizza, he is like lay it on pizza, and u simply want him to show u how to lay down dough, sauce on it, pepperoni on top and cheese, once u see a completed pizza u know how to make a new one, why is he going around it like rain around Fresno. Edited April 17, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 17, 2013 Share Posted April 17, 2013 Omfg. Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 17, 2013 Author Share Posted April 17, 2013 (edited) what happened i m honest since im not trying to be rude to anyone, any help here will be greatly appreciated. Edited April 17, 2013 by BRYANBRYAN Quote Link to comment Share on other sites More sharing options...
BRYANBRYAN Posted April 18, 2013 Author Share Posted April 18, 2013 are there only 2 gurus on this site? Quote Link to comment 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.