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
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 12:39 am
Can't seem to get the syntax correctly can anyone assist me with this, would greatly appreciated.
here is the code..
Code: Select all
if (($step > 1) && (!$not_found)) {
$products = tep_db_fetch_array($products_query)
if count($products)=1 {
$product_array = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
} else {
$product_array = array(array('id' => 0, 'text' => TEXT_SELECT_PRODUCT));
while($products = tep_db_fetch_array($products_query)) {
$product_array[] = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
}
}
This is probably one of many questions to come, since I am no where near to be a programmer or coders, but I enjoy this so much, I just can't stay away from it LOL
Anyways any help is more that welcome.....
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Thu Oct 30, 2008 1:28 am
Need a
; after
$products = tep_db_fetch_array($products_query)
Would be more helpful next time if you could post the syntax error message you are receiving.
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.
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 7:20 am
Thanks and will do so in the future....
New code:
Code: Select all
if (($step > 1) && (!$not_found)) {
$products = tep_db_fetch_array($products_query);
if count($products)=1 {
$product_array = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
} else {
$product_array = array(array('id' => 0, 'text' => TEXT_SELECT_PRODUCT));
while($products = tep_db_fetch_array($products_query)) {
$product_array[] = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
}
}
That gives me that error now
"Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/hsmmqs/public_html/catalog/admin/edit_orders_add_product.php on line 247"
line 247 = line 4
Syntac
Forum Contributor
Posts: 327 Joined: Sun Sep 14, 2008 7:59 pm
Post
by Syntac » Thu Oct 30, 2008 2:16 pm
Should be:
Conditions must always be encased in parentheses.
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 2:57 pm
Thanks will test it
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 3:02 pm
NOw i'm getting this:
Fatal error: Can't use function return value in write context in .../edit_orders_add_product.php on line 247
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Thu Oct 30, 2008 3:23 pm
There were two problems with that line: the parentheses and the =.
= is for assignment. == is for comparison.
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 4:05 pm
Regardless of what I put == or =
Here is the code:
Code: Select all
if (($step > 1) && (!$not_found)) {
$products = tep_db_fetch_array($products_query)
if (count($products)=1) {
$product_array = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
} else {
$product_array = array(array('id' => 0, 'text' => TEXT_SELECT_PRODUCT));
while($products = tep_db_fetch_array($products_query)) {
$product_array[] = array('id' => $products['products_id'], 'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
}
}
Still give me this error:
syntax error, unexpected T_IF in
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 4:09 pm
Maybe I should explain what I was hoping to achieve with that code.
Basically if there is only one result from the search I want it to be selected right away
and if there is more than one results I want my popup that there!
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 4:19 pm
Actually, thinking about this might asswell submit the form since they will be nothing to do!
Code: Select all
if (isset($_POST['add_product_options'])) {
foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
echo '<input type="hidden" name="add_product_options['.$option_id.']" value="' . $option_value_id . '">';
}
}
echo '<input type="hidden" name="add_product_categories_id" value="' . $add_product_categories_id . '"><input type="hidden" name="add_product_products_id" value="' . $add_product_products_id . '"><input type="hidden" name="step" value="5"></td>' . "\n" .
' </tr>' . "\n" .
' </form>' . "\n";
}
I think this the section that submits the result to the invoice not sure....
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Thu Oct 30, 2008 4:45 pm
kidney514 wrote: Still give me this error:
syntax error, unexpected T_IF in
Kinda frustrating when the code you post changes...
This time you deleted a semicolon from the line before the if. It was there before but isn't now.
kidney514
Forum Newbie
Posts: 8 Joined: Thu Oct 30, 2008 12:35 am
Post
by kidney514 » Thu Oct 30, 2008 4:50 pm
Wasnt the plan, I just made a mistake... Nothing else, but thanks for pointing it out.......