php site returns >

Asked

Viewed 64 times

1

My page is returning > minor sign when add the following code that is commented:

<form name="form_import" id="form_import" method="post" action="<?php echo $_endereco ?>" enctype="multipart/form-data">
  <table class="formulario">
    <tbody>
      <tr class="cabecalho">
        <th colspan="2">
          Agraves - importar
        </th>
      </tr>
      <tr>
        <th>
          <label>Tipos de Agreve</label>
        </th>
      </tr>
      <tr>  <th></th>
        <td>
          <a href="upload_foto/agrave_pdf.php">
            <ul>
              <li>Agrave 4 salarios</li>
              <li>agrave 10 salarios</li>
            </ul>
          </a>
        </td>
      </tr>
      <tr>
        <th>
          <label>Arquivo </label>
        </th>
        <td>
          <input type="file" name="arquivo" id="nome_arquivo"/>
        </td>
      </tr>
      <tr class="rodape">
        <td colspan="2">
          <input type="hidden" name="advogado" id="acao" value="<?php echo $_SERVER['PHP_SELF']."?login=$_SESSION['_codigo_usuario']"; ?>">
          <button type="submit" src="mgm/importa.png" alt="Importar" class="elemento_a_direita"/>Importar
        </td>
      </tr>
    </tbody>
  </table>
</form>
  • 1

    I tried to reproduce the error and did not succeed, you can provide a better snippet of the code?

2 answers

1

Your code is wrong on the line:

<input type="hidden" name="advogado" id="acao" value="<?php echo $_SERVER['PHP_SELF']."?login=$_SESSION['_codigo_usuario']"; ?>">

See (not) working on Ideone.

If the intention is to concatenate the session value in string, the simplest is to remove it from within it:

<input type="hidden" name="advogado" id="acao" value="<?php echo $_SERVER['PHP_SELF']."?login=".$_SESSION['_codigo_usuario']; ?>">

See working on Ideone.

Or use keys to properly format the string:

<input type="hidden" name="advogado" id="acao" value="<?php echo "{$_SERVER['PHP_SELF']}?login={$_SESSION['_codigo_usuario']}"; ?>">

See working on Ideone.

Related question:

What is { } for in the code below? and what is the definition?

-1

try to remove the two bars after concatenation:

   <form name="form_import" id="form_import" method="post" action="<?php echo $_SERVER['PHP_SELF']."?login=$_SESSION['_codigo_usuario']"; ?>" enctype="multipart/form-data">
  • 2

    But the two bars is what defines the comment. Why remove them?

  • 1

    And why would you have a comment in the middle of a line of code?

  • @Sergio why I don’t know, but it’s a valid and documented syntax. See a example and the documentation on the comments.

  • @Andersoncarloswoss, all the examples you showed, the comments are on a line end. In the case of the above code, the comment is in the middle of a command, making all the rest of the code to be considered a comment as well. php ignores where the comment starts "...to the end of the line or block...", as it says in the documentation itself.

  • @Exact Sergio. Initially the author put that the code was commented on implying that the intention was that it be ignored.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.