redarrow Posted September 5, 2006 Share Posted September 5, 2006 i need to know if my mysql_num_rows is correct please cheers.[code]<?php$query2="select * from payment_info where id='$id'";$result2=mysql_query($query2);if(mysql_num_rows($result2)==1){so some think update members info}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/ Share on other sites More sharing options...
zq29 Posted September 5, 2006 Share Posted September 5, 2006 Looks ok to me, what's the problem you are having? Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86190 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 what i want to do if there more then one entry of the same information in a database field is delete that entery.i come up with this but should it work cheers mate.but the problam is that only one of the entrys need to be deletedor can i set the userid to unique[code]<?php$query="select * from payment_info where id='$id'";$result=mysql_query($query);if(mysql_num_rows($query)>1){$delete="delete from payment_info where id='$id' ";$delete_query=mysql_query($delete); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86194 Share on other sites More sharing options...
zq29 Posted September 5, 2006 Share Posted September 5, 2006 I take it that your code is deleting all of the rows with the supplied id, and not just the duplicates, right? I think it might help if you use a LIMIT in your DELETE query...[code]<?php$result = mysql_query("SELECT * FROM `payment_info` WHERE `id`='$id'") or die(mysql_error());$count = mysql_num_rows($result);if($count > 1) { $limit = $count - 1; mysql_query("DELETE FROM `payment_info` WHERE `id`='$id' LIMIT $limit") or die(mysql_error());}?>[/code]ID fields are commonly regarded as unique fields, if you are finding you have ID fields with the same numbers in you have a problem somewhere. Deleting those fields is not the solution, preventing them from appearing in the first place would be more ideal. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86198 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 i think that code will work cheers.I tell you the whole story so you see what's happening, a user goes to pay for a service if the user just close there browser the information for that user will be in a temp field but when the user does pay the temp field updates the correct field but both entrys enter .so what do you do?the only way around that situation is delete one entry get me. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86199 Share on other sites More sharing options...
radar Posted September 5, 2006 Share Posted September 5, 2006 delete from payment where id = $id will delete them all though.. if you put in the end of the delete clause limit = 1 it will only delete one. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86200 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 what about if the user close the broweser 6 times before payment then i have 6 user enterys then what ?please help lol. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86202 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 i am sure that the code SemiApocalyptic has provided will do what i wont where it counts the number of entrys then deletes all except 1.is that correct works so far please advise me cheers. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86203 Share on other sites More sharing options...
zq29 Posted September 5, 2006 Share Posted September 5, 2006 I think I understand, but why are several records getting the same ID? If the user closes his browser 6 times and then pays on the 7th, I'd assume you'd only want the seventh basket marked as paid with the other 6 being left marked as 'abandoned basket'.Why are you storing the baskets in a temporary table anyway? For saving abandoned baskets, or so that if a user does close their browser their basket is saved for their next visit? Even still, I don't understand how you're getting duplicate rows in the table... Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86205 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 SemiApocalyptic what it is that a user can only pay for the service once they activate there account then they login then pay so that why an id is there ok.it's nearly finished now the system i am working on is a paypal system with ipn but to be sure to be sure ok.this how my website does work and works fine and is good and gooing good.1. a user makes a account and also provides relevent information they want to show the world.2. afther the account is made the users has to activate the account via a link in there email box.3. when the user first goto the web address and logs in they get redireted to a payment paln the user selects a payment plan then thay confirm with a paypal button they and pay paypal for the my service .4. paypal sends all information back to my ipn system then i check if the payment is the payment that they wanted incase they change the form encripted or not it's easy as you all no.5. then the user logs in and can edit delete and modify anythink they want as there on there own members page.thank you for your help all worked well cheers. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86206 Share on other sites More sharing options...
Zane Posted September 5, 2006 Share Posted September 5, 2006 maybe I'm understanding this wrong....are you appending the non paying user info inside the same table as the paying users' info?another question[quote]what it is that a user can only pay for the service once they activate there account then they login then pay so that why an id is there ok.[/quote]..what?so do they pay for the activation and then pay for something else when they ARE activated?I'm lost Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86209 Share on other sites More sharing options...
redarrow Posted September 5, 2006 Author Share Posted September 5, 2006 zanus read this please ok cheers.1. a user makes a account and also provides relevent information they want to show the world.2. afther the account is made the users has to activate the account via a link in there email box.3. when the user first goto the web address and logs in they get redireted to a payment paln the user selects a payment plan then thay confirm with a paypal button and pay via paypal for the my service .4. paypal sends all information back to my ipn system then i check if the payment is the payment that they wanted incase they change the form encripted or not it's easy as you all no.5. then the user logs in and can edit delete and modify anythink they want as there on there own members page.6.when the users time is up the account gets deleted that it!thank you for your help all worked well cheers. Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86211 Share on other sites More sharing options...
radar Posted September 5, 2006 Share Posted September 5, 2006 Well if the user closes the browser 6 times perhaps your best bet would be to store all the info into some strings.. delete all instances of it and then re-insert one... Quote Link to comment https://forums.phpfreaks.com/topic/19742-mysql_num_rows-help-very-quick-question-cheers/#findComment-86688 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.