Jump to content


Photo

mysql_num_rows help very quick question cheers.


  • Please log in to reply
12 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 06:27 AM

i need to know if my mysql_num_rows is correct please cheers.

<?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

}
?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 05 September 2006 - 06:32 AM

Looks ok to me, what's the problem you are having?

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 06:38 AM

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 deleted

or can i set the userid to unique
<?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); 

}

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 05 September 2006 - 06:48 AM

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...
<?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());
}
?>

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.

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 06:53 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 05 September 2006 - 06:59 AM

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.

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 07:02 AM

what about if the user close the broweser 6 times before payment then i have 6 user enterys then what ?

please help lol.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 07:04 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 05 September 2006 - 07:10 AM

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...

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 07:12 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 05 September 2006 - 07:25 AM

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

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.


..what?
so do they pay for the activation and then pay for something else when they ARE activated?
I'm lost

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 September 2006 - 07:30 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#13 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 05 September 2006 - 09:22 PM

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... 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users