Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Some PHP help.


Brunswick

Recommended Posts

Posted

Hi all you PHP gurus out there.

 

I've hit a slight "bump in the road" with a line of PHP code. I'm using this in the header.php file.

 

The original line reads:

 

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?>

I've successfully modified this like so (which works well)

 

<td width=43% align=center valign="middle"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'logo.jpg', 'Kandy Land') . '</a>'; ?></td>	
<td width=24% align="center" valign="bottom">
<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'standrews.jpg', 'Kandy Land') . '</a>'; ?><br><br><br><br>

<?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', 
HEADER_TITLE_MY_ACCOUNT) . '</a>  <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>  <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>'; ?>  </td>

<td width=33% align=center valign="middle"><?php echo '<a href="chewy.html">' . tep_image(DIR_WS_IMAGES . 'chewyguide.jpg', 'Kandy Land') . '</a>'; ?></td>

This allows me to have a number of images nicely co-exist in the header with the last one linking to a file called "chewy.html"

 

So far so good. this is all working.

 

Now I would like to change the link in the last line to:

 

<?php echo '<a href="" onclick="return newwindow('chewy.html')">' . tep_image(DIR_WS_IMAGES . 'chewyguide.jpg', 'Kandy Land') . '</a>'; ?>

In regular html that would open a pop-up window with the linked file inside. (Using some javascript) Even that works outside of PHP because I tried it in this header file. However it doesn't seem to like it as shown above because it generates the following error message:

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\athome\kandy\catalog\includes\header.php on line 96

I'm gradually teaching myself PHP but this is just a little beyond my skillset sofar.

 

I'm hoping someone can point me to the problem here. My original code does let me link successfully to "chewy.html" but it would suit my purposes better if I could use the "pop-up".

 

Thank you,

 

-Hank :)

Posted
Hi all you PHP gurus out there.

I hope you don't mind I try to answer this...

 

I think it will work if you put a backslash before the single quotes in the java script:

<?php echo '<a href="" onclick="return newwindow(\'chewy.html\')">' . tep_image(DIR_WS_IMAGES . 'chewyguide.jpg', 'Kandy Land') . '</a>'; ?>

Posted

Hello Jan,

 

I don't mind at all. :)

 

Also you were absolutely correct. It worked perfectly! Goes directly to the pop-up.

 

Thank you very much for the help! As usual, the php error message was vague and pretty misleading.

 

I had an idea that escape characters might be the issue so I carefully "escaped" all the double quotes. That made no difference. Didn't think to try the single quotes. :(

 

Anyway, this is good! Thank you again, very much.

 

Best,

 

-Hank

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...