comma use?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

comma use?

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

php will not normally skip commas.. might want to check how your variables are being set up..
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

Post 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.
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post 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.
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

Post 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,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

do a phpinfo() on the recieving end..
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

Post 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
Post Reply