-1

i wanna test if my variable is empty or not to display some differents things. When i don't use the else...if everything work but when i use this code :

<?php 
$Amazon = get_post_meta($post->ID, "Lien Amazon", true);
?>
<?php   
    if( $Amazon != NULL ){ 
        echo '<li><span class="post-meta-key"><a href=". $Amazon . ">Acheter sur Amazon</a></li>' ;} 
    else {
        echo '<li><span class="post-meta-key"><a href="https://www.amazon.fr/bd/b?ie=UTF8&node=301133">Acheter sur Amazon</a></li>' ;}  
        ?>

What is the problem ? Thank you

Flushdrew
  • 133
  • 1
  • 10
  • 5
    What has the title to do with the question? What is the problem? – Rizier123 May 15 '16 at 15:15
  • `when i use this code` then WHAT? – u_mulder May 15 '16 at 15:16
  • Your amazon link can't work as you miss two single quotes around your concat. But this code can never generate an infinite loop - there is not even a regular one – clemens321 May 15 '16 at 15:17
  • Sorry , when i used this code my page charged infinitely and nothing happen.Where are the missing two singles quotes ? – Flushdrew May 15 '16 at 15:20
  • 1
    "What is the problem ? Thank you" - The problem is simple. You provide poor information. [How do I ask a good question](http://stackoverflow.com/help/how-to-ask) / [How to create a minimal, complete and verifiable example](http://stackoverflow.com/help/mcve) – Pinke Helga May 15 '16 at 15:24
  • I'm sorry i'm french so excuse my english.When i use the else...if nothing happen and my page stay blank.When i use the same code without the else...if everything work perfectly. – Flushdrew May 15 '16 at 15:28
  • "but my page stays blank" --> http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – Sumurai8 May 15 '16 at 15:35

1 Answers1

1

Here is an output error. You haven't closed and reopened the string on trying to concat a variable.

echo '<li><span class="post-meta-key"><a href=". $Amazon . ">Acheter sur Amazon</a></li>' ;

Do instead:

echo '<li><span class="post-meta-key"><a href="'. $Amazon . '">Acheter sur Amazon</a></li>' ;
Pinke Helga
  • 6,378
  • 2
  • 22
  • 42