title: PHP - Why its not printing the variable although it prints text?
body: <p>I had some problem with this php cause it was not returning anything from the DB, so I realised that maybe it was not receiving the variable from the $_POST. So I tried to print it and it didnt return nothing. So ive entered its value manually, but it stills printing nothing! Although it prints texts, if there was a syntax problem in the script it wouldn't print the texts too (i think). So I don't know what is wrong.</p>
  
  <p>The HTML part with the tables get printed!
  At the end there is a "echo "anything";" and it is also printed! The only thing that is not printed is the $nome variable.</p>
  
  <p>Sorry for the portuguese texts, but you don't need to worry about them.</p>
  
  <pre><code>    &lt;?php
  
          //$nome = $_POST['nome'];
          $nome = "renato";  //ive set the value manually for tests
  
          $pdo = new PDO('mysql:host=myserver;dbname=mydb', 'myuser', 'mypw');
  
  
          if ($nome = ""){
              $sql = $pdo-&gt;query("SELECT * FROM clientes");
          }
          else{
              $sql = $pdo-&gt;query("SELECT * FROM clientes WHERE nome='".$nome."'");
          }
  
          echo $nome; //prints nothing!
      ?&gt;
  
      &lt;table border="1px"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;h3&gt;ID&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;NOME&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;ENDERECO&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;BAIRRO&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;CIDADE&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;FIS_JUR&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;RG&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;CPF&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;TEL&lt;/h3&gt;
              &lt;/td&gt;&lt;td&gt;
                  &lt;h3&gt;TEL2&lt;/h3&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h3&gt;DATA_NASC&lt;/h3&gt;
              &lt;/td&gt;       
          &lt;/tr&gt;
  
  
  //this table gets printed!
  
  
      &lt;?php
  
          while($row = $sql-&gt;fetch(PDO::FETCH_ASSOC)){
          echo "
          &lt;tr&gt;
              &lt;td&gt; {$row['id']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['nome']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['endereco']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['bairro']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['cidade']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['fis_jur']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['rg']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['cpf']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['tel']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['tel2']}
              &lt;/td&gt;
  
              &lt;td&gt; {$row['data_nasc']}
              &lt;/td&gt;
          &lt;/tr&gt;";
  
  //this one prints nothing!
          }
  
          echo $nome; //prints nothing
          echo "anything"; //yes, this one gets printed
          $pdo = null;
          $sql = null;
      ?&gt;
          &lt;/table&gt;
  </code></pre>