Forum Moderators: coopster

Message Too Old, No Replies

table into echo problems

         

srtlv

7:33 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



Hello!
I'm begginer @ php, I get error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 
echo "<tr>
<td valign=\"top\"> <a href=\"<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>\"> <?=tep_image(DIR_WS_IMAGES.$new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=\"bd\"')?></a></td>
<td width=\"30\"></td>
<td width=\"236\" valign=\"top\"><br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a class=\"ml3\" href=\"<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>\"> <?=$new_products['products_name']?></a><br style=\"line-height:1px;\"> <br style=\"line-height:10px;\">
<?=preg_replace('/\s\S*$/i', '', substr($new_products['products_description'], 0, 120))?>...<br style=\"line-height:1px;\"><br style=\"line-height:9px;\">
<span class=\"tx4\"><?=$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))?></span><br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a href=\"<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>\"> <?=tep_image_button(\"button_details.gif\");?></a> <a href=\"<?= tep_href_link(\"products_new.php\", \"action=buy_now&products_id=\".$new_products['products_id'])?>\"> <?=tep_image_button(\"button_add_to_cart.gif\");?></a>
</td></tr>";

[edited by: eelixduppy at 9:03 pm (utc) on June 24, 2007]
[edit reason] fixed sidescroll [/edit]

eelixduppy

9:07 pm on Jun 24, 2007 (gmt 0)



Hello, srtlv, and Welcome to WebmasterWorld!

Your syntax for string concatenation is incorrect. As an example of how it should be done, it would look like the following (not showing all the code):


echo "<tr>
<td valign=\"top\"> <a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">". tep_image(DIR_WS_IMAGES.$new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=\"bd\"')."</a></td>"; #etc...

Try to format the rest of the string the same way and you should be fine. You may want to refer to the string documentation [us2.php.net] for additional information, as well.

Good luck! :)

srtlv

9:13 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



Big thanks, I will give a try to format all text that way and after 30 minutes I will give an answer.

srtlv

10:08 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



Thanks, I have already managed to understand this syntax. But the problem is with the last row.

How it looks:

<a href=\"<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>\"> <?=tep_image_button(\"button_details.gif\");?></a> <a href=\"<?= tep_href_link(\"products_new.php\", \"action=buy_now&products_id=\".$new_products['products_id'])?>\"> <?=tep_image_button(\"button_add_to_cart.gif\");?></a>

And how i made it:

<a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">". tep_image_button(\"button_details.gif\");."</a> <a href=\"".tep_href_link(\"products_new.php\", \"action=buy_now&products_id=\".$new_products['products_id'])."\"> ".tep_image_button(\"button_add_to_cart.gif\");."</a> 

I get 2 errors:
Warning: Unexpected character in input: '\' (ASCII=92) state=1
Parse error: syntax error, unexpected '/'

eelixduppy

11:59 pm on Jun 24, 2007 (gmt 0)



Remove the semi-colon after each of the function calls; it is messing up the string.

Note: Don't remove the semi-colon from the very end, though. :)

srtlv

12:25 am on Jun 25, 2007 (gmt 0)

10+ Year Member



Yes, I removed thou's two semi colons, but i still get the same error (on the same lane).

here is the new echo fully

echo "<td valign=\"top\"> <a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">". tep_image(DIR_WS_IMAGES.$new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=\"bd\"')."</a></td>
<td width=\"30\"></td>
<td width=\"236\" valign=\"top\"><br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a class=\"ml3\" href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id']."\">". $new_products['products_name']."</a><br style=\"line-height:1px;\"><br style=\"line-height:10px;\">
".preg_replace('/\s\S*$/i', '', substr($new_products['products_description'], 0, 120))."...<br style=\"line-height:1px;\"><br style=\"line-height:9px;\">
<span class=\"tx4\">".$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))."</span><br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">". tep_image_button(\"button_details.gif\")."</a> <a href=\"".tep_href_link(\"products_new.php\", \"action=buy_now&products_id=\".$new_products['products_id'])."\"> ".tep_image_button(\"button_add_to_cart.gif\")."</a>
</td></tr>";

SixTimesEight

1:03 am on Jun 25, 2007 (gmt 0)

10+ Year Member



osCommerce can be a pain. Try this:

echo "
<td valign=\"top\"><a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">". tep_image(DIR_WS_IMAGES.$new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'class=\"bd\"')."</a></td>
<td width=\"30\"></td>
<td width=\"236\" valign=\"top\">
<br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a class=\"ml3\" href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id']."\">". $new_products['products_name']."</a>
<br style=\"line-height:1px;\"><br style=\"line-height:10px;\">"
.preg_replace('/\s\S*$/i', '', substr($new_products['products_description'], 0, 120))."...
<br style=\"line-height:1px;\"><br style=\"line-height:9px;\">
<span class=\"tx4\">".$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))."</span>
<br style=\"line-height:1px;\"><br style=\"line-height:5px;\">
<a href=\"".tep_href_link('product_info.php?products_id='.$new_products['products_id'])."\">".tep_image_button('button_details.gif')."</a>
<a href=\"".tep_href_link('products_new.php', 'action=buy_now&products_id='.$new_products['products_id'])."\">".tep_image_button('button_add_to_cart.gif')."</a>
</td></tr>";