Voland Posted August 19, 2006 Share Posted August 19, 2006 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 More sharing options...
jasonabc Posted August 19, 2006 Share Posted August 19, 2006 you have a couple of single quotes in the wrong place. Change it to this: echo '<a href="'tep_href_link('FILENAME_LOGIN', '', 'SSL') '">' tep_image(DIR_WS_IMAGES . 'log_in.gif') '</a>'; Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix Link to comment Share on other sites More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 ok i iwll try that in a minute. SHould I concatinate eith th "." opperator? Thanks People dont change, people realize. Link to comment Share on other sites More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 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 More sharing options...
jasonabc Posted August 19, 2006 Share Posted August 19, 2006 My bad - yes you should. This works (I tested on a fresh install of OSC): echo '<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'log_in.gif') . '</a>'; Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix Link to comment Share on other sites More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 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 More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 I mean do I need the { brackets anywhere? or are they not nessesarry in this case? People dont change, people realize. Link to comment Share on other sites More sharing options...
jasonabc Posted August 19, 2006 Share Posted August 19, 2006 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. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix Link to comment Share on other sites More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 :) 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 More sharing options...
jasonabc Posted August 19, 2006 Share Posted August 19, 2006 So would I be right to conclude that using the brackets is a better syntax practice? Correct. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix Link to comment Share on other sites More sharing options...
Voland Posted August 19, 2006 Author Share Posted August 19, 2006 Thanks Jason People dont change, people realize. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.