Query does not return results in PHP [closed]

0

There is a query in my PHP where I search the mailing list and return to PHP, however, it is not returning any results.

Code PHP looks like this:

      <?php
      session_start("admin");
      if($_SESSION["admin"] == "on"){
      include("../config.php");
      ?>
      <?php
      $sql = mysql_query("SELECT 'email' FROM 'n_emails' WHERE 1");
      $resultado = mysql_query($sql) or die(mysql_error());
      while($lista2=mysql_fetch_array($resultado)) {
      $email = $lista2["email"];
      $ativo = $lista2["ativo"];
      if($ativo=="n"){
      $ativo = "<font face='Arial' size='2' color='red'>Não confirmado</font>";
      }
      else{
      $ativo = "<font face='Arial' size='2' color='green'>Confirmado</font>";
      }
      ?>
      <tr>
      <td width="50%">
      <p align="center"><b><font face="Arial" size="2"><?=$email?></font>          </b></td>
      <td width="25%"><?=$ativo?></td>
      <td width="25%"><a href="javascript:remove('<?=$email?>')">
      <font face="Arial" size="2">remover</font></a></td>
      </tr><?php } ?>
      <?php
      }
      else{
      echo "<script>location.href='login.php'</script>";
      }
      ?>

When I run this query manually, it returns me the results all correct. I do not understand what is happening.

    
asked by anonymous 16.03.2016 / 15:59

1 answer

1

Solution to the problem, I changed the query:

  SELECT 'email' FROM 'n_emails' WHERE 1

by this:

  SELECT * FROM n_emails order by -id

And it worked.

    
16.03.2016 / 16:27