Page 1 of 1

comma use?

Posted: Mon Aug 08, 2005 1:32 pm
by br5dy
I have a payment company that I use for my website, and on one of their variables passed back to my script, $merchant_product_id, if having more than one item, it should be separated by commas, like product1, product2, product3, and if having only one item on the order, just product1.

However, every time I echo the variable, it returns only one of the products, even on multiple order items. I've e-mailed them about it and they say it works, but I didn't know if there's anything PHP skips over because of commas?

Thanks,
Brady

Posted: Mon Aug 08, 2005 1:37 pm
by feyd
php will not normally skip commas.. might want to check how your variables are being set up..

Posted: Mon Aug 08, 2005 3:38 pm
by s.dot
perhaps they are being stored in separate database rows, and you need to loop through the results.

Code: Select all

$result = mysql_query("SELECT merchant_product_id FROM table WHERE value = '$value'");
while($array = mysql_fetch_assoc($result))
{
   echo $array['merchange_product_id'];
}
That's assuming you're using a mysql database.
Edit: It also assumes you're using a database.

Posted: Tue Aug 09, 2005 2:43 am
by br5dy
good thought, but it's actually just a variable that's passed on through the page to my server. so i can't connect to the database cuz it's third party.

Posted: Tue Aug 09, 2005 3:59 am
by Skittlewidth
Just a thought, but I've had a problem with variables being cut off before and it was to do with echoing them into a form field. I'd forgotten to enclose the php statement in quotes:

Code: Select all

<input name='blah' type='text' value= '<?php echo $var; ?>'/>
so the contents of the variable were being cut off at the first space, which in your case would probably occur after the first comma.

You didn't say how you were echoing the variable out so this might be entirely irrelevant though.

Posted: Tue Aug 09, 2005 4:00 pm
by br5dy
I tried what you said, but still no luck.

The variable is passed to page goodorder.php, then from there it's passed to order_end.php

I've echoed the variable from both pages and still receive only one item.

Any ideas?

Thanks,

Posted: Tue Aug 09, 2005 4:07 pm
by feyd
do a phpinfo() on the recieving end..

Posted: Wed Aug 10, 2005 7:44 pm
by br5dy
Thanks a lot people, the CC company failed to explain the variables. If there are more than one the the number is added to the variable name. Such as, $product, $product1. It's not seperated by commas.

8O