Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

minor PHP syntax help


Voland

Recommended Posts

Hi all,

 

I am trying to implement the following behaivior in my header.php file. I want a log_in/log_off button that switches to being a log_in or log_off depending whether a user logged in or not. I think I understand teh logic of doing so but keep getting the "unexpected T_STRING" errors. what I have right now is this

 

<tr><td>

		   <?php
		   if (!tep_session_is_registered('customer_id')) {
		   echo '<a href="'tep_href_link('FILENAME_LOGIN, '', 'SSL'') '">' tep_image(DIR_WS_IMAGES . 'log_in.gif') '</a>';}
			 ?>			  

		   </td></tr>

 

I havnt gotten to the "esle" portion of the IF statement yet.

 

Please somone help me to write out this logic

 

Thank you fo ryour time,

 

Arkady.

People dont change, people realize.

Link to comment
Share on other sites

Jason,

It didint work I changed it to what you sugested

 

<?php
		   if (!tep_session_is_registered('customer_id')) {
		   echo '<a href="'tep_href_link('FILENAME_LOGIN', '', 'SSL') '">' tep_image(DIR_WS_IMAGES . 'log_in.gif') '</a>';}



			 ?>

 

and I get the follwoing error

 

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/shop/includes/header.php on line 152

 

Line 152 is teh one where the echo statement is

People dont change, people realize.

Link to comment
Share on other sites

Perfect!

 

here is my code :)

 

  <?php
		   if (!tep_session_is_registered('customer_id')) 
		   echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'log_in.gif') . '</a>';

else if (tep_session_is_registered('customer_id')) 

	echo '<a href="' . tep_href_link(FILENAME_LOGOFF, '', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'log_off.gif') . '</a>';	   



			 ?>

 

It seems to work as intended, but can you please look it over and tell if I'm not missing anything?

 

Thanks

People dont change, people realize.

Link to comment
Share on other sites

well rather than posting such questions on here - try a bit of trial and error and see for yourself? Does it break if you leave the brackets out? If so then you probably need to insert them....!

 

If it is still broken then your problem lies elsewhere. Use the server error logs nad PHP error reporting to debug your code - it's an essential part of OSC development.

Link to comment
Share on other sites

:) Deal, I will try. I do usually try to solves things myself first. I guess im just very much pressed for time today. Anyway it works both ways I incerted the brackets like so

 

<?php if (!tep_session_is_registered('customer_id')) { echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'log_in.gif') . '</a>';

			}else if (tep_session_is_registered('customer_id')){  echo '<a href="' . tep_href_link(FILENAME_LOGOFF, '', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'log_off.gif') . '</a>';}?>

 

So would I be right to conclude that using the brackets is a better syntax practice?

 

Thank you.

People dont change, people realize.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...