lingo5 Posted December 30, 2011 Share Posted December 30, 2011 Hi, i,m trying to echo a "a href" based on the language session of my page like this: ?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } { else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?> but I'm getting a blank page wit no errors...must be a syntax error that I can't spot... Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/ Share on other sites More sharing options...
AyKay47 Posted December 30, 2011 Share Posted December 30, 2011 <?php $idioma = $_SESSION['session_idioma']; if ($idioma == "eng") { ?> <a href="preordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a> <?php }else { ?> echo '<a href="ordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302576 Share on other sites More sharing options...
melloorr Posted December 30, 2011 Share Posted December 30, 2011 echo "<a href=\"preordering.php\"><img src=\"img/top_banner_'.$_SESSION['session_idioma'].'.jpg\" width=\"744\" height=\"182\"></a>\"; Does this work for the top one? *Nevermind Ignore mine * Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302577 Share on other sites More sharing options...
Muddy_Funster Posted December 30, 2011 Share Posted December 30, 2011 Hi, i,m trying to echo a "a href" based on the language session of my page like this: ?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } { else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?> but I'm getting a blank page wit no errors...must be a syntax error that I can't spot... your else is actualy within / after it's own opening brace... Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302581 Share on other sites More sharing options...
lingo5 Posted December 30, 2011 Author Share Posted December 30, 2011 Thanks Muddy, I have tried with the else before the opening brace like so... <?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } else { echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?> ..still no luck. ayKay, tried your suggestion also but same blank page pops up... Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302584 Share on other sites More sharing options...
KevinM1 Posted December 30, 2011 Share Posted December 30, 2011 That's because you're missing the closing ) on your if-conditional. Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302591 Share on other sites More sharing options...
Muddy_Funster Posted December 30, 2011 Share Posted December 30, 2011 You also have you if brackets closing too soo... how about a slightly different slant on it: <?php $idioma = $_SESSION['idioma']; if ($idioma=="eng") { $prefix= '<a href="preordering.php"><img src="img/top_banner_'; } else { $prefix='<a href="ordering.php"><img src="img/top_banner_'; } $suffix = '.jpg" width="744" height="182"></a>'; $urlLink = $prefix.$idioma.$suffix; echo "It Worked!! >>>>".$urlLink; ehco "<br><pre>". $urlLink."</pre></br>"; ?> I flung the extra bit in there in case it's a problem with the URL for the img src. Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302593 Share on other sites More sharing options...
Pikachu2000 Posted December 30, 2011 Share Posted December 30, 2011 $pre = $_SESSION['session_idioma'] == 'eng' ? 'pre' : ''; echo "<a href=\"{$pre}ordering.php\"><img src=\"img/top_banner_{$_SESSION['session_idioma']}.jpg\" width=\"744\" height=\"182\"></a>"; Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302599 Share on other sites More sharing options...
AyKay47 Posted December 30, 2011 Share Posted December 30, 2011 edit to my post: <?php $idioma = $_SESSION['session_idioma']; if ($idioma == "eng") { ?> <a href="preordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a> <?php }else { ?> <a href="ordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302600 Share on other sites More sharing options...
lingo5 Posted December 30, 2011 Author Share Posted December 30, 2011 Thanks all for your help...I've tried all your suggestions and they all work!!!!... Pikachu your solution kind of rules.... Quote Link to comment https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/#findComment-1302604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.