Jump to content

Please help with syntax


lingo5

Recommended Posts

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...

Link to comment
Share on other sites

<?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 
}
        ?>

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 
}
        ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.