Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

oscar_marques

[Resolvido] Erro ao imprimir em session

Recommended Posts

Boa tarde a todos. Estou recebendo uma mensagem de erro:

 

Parse error: syntax error, unexpected '=', expecting '}' in /home/site/www/pag.php on line 44

 

essa mensagem faz referencia a linha:

 

if (isset(".$_SESSION['DiaDataNascimento'].")){$DiaDN='".$_SESSION['DiaDataNascimento']."';}

 

Creio que seja por conta da declaração da varivel que recebe a resgatada pela session.

 

Erro semelhante era indicado na linha:

 

<? if (isset($_SESSION['Nome'])){echo "</b><b>" . $_SESSION['Nome'];} ?>

 

mas resolvi este erro com as aspas e ponto ficando assim:

 

<? if (isset(".$_SESSION['Nome'].")){echo '</b><b>' " . $_SESSION['Nome'].";} ?>

 

Alguem que ja tenha passado por problema semenhante ou quem que tenha alguma ideia, poderia dar uma força aí!?!

 

Desde já agradeço!

 

Abraço a todos!!

 

 

 

Eis o código na íntegra:

 

<?
session_start();
$_SESSION['Nome']=$_POST['Nome'];
$_SESSION['DiaDataNascimento']=$_POST['DiaDataNascimento'];
$_SESSION['MesDataNascimento']=$_POST['MesDataNascimento'];
$_SESSION['AnoDataNascimento']=$_POST['AnoDataNascimento'];
$_SESSION['login']=$_POST['login'];

if (isset($_SESSION['login'])){
	echo 

print "

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title></title>
<style type='text/css'>
  body {background-color: #ffffff;}
  .style17 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
</style>
</head>

<body>
<table width='100%' border='0' align='center'>
  <tr><form method=post action=proxpagina.php>
    <td bordercolor='#c19f62' scope='col'><table width='100%' border='0' cellpadding='0' cellspacing='0'>
      <tr>
        <th colspan='3' scope='col'><div align='left'><span class='style22'>Dados</span></div></th>
      </tr>
      <tr>
        <td width='39%'><div align='right' class='style17'>Nome</div></td>
        <td width='1%'></td>
        <td width='60%'><div align='left'><span class='style17'>
          <? if (isset(".$_SESSION['Nome'].")){echo '</b><b>' " . $_SESSION['Nome'].";} ?>
        </span></div></td>
      </tr>
      <tr bgcolor='f6efd2'>
        <td><div align='right' class='style17'>Data Nascimento </div></td>
        <td><span class='style16'></span></td>
        <td><div align='left'><span class='style17'>
          <?
	    if (isset(".$_SESSION['DiaDataNascimento'].")){$DiaDN='".$_SESSION['DiaDataNascimento']."';}
            if (isset($_SESSION['MesDataNascimento'])){$MesDN=$_SESSION['MesDataNascimento'];}
            if (isset($_SESSION['AnoDataNascimento'])){$AnoDN=$_SESSION['AnoDataNascimento'];}
                ?>
        </span></div></td>
      </tr>
      <tr>
        <td colspan='3'><table width='100%'>
          <tr>
            <th width='8%' scope='col'> </th>
            <th width='38%' scope='col'><div align='right'><strong><a href='http://www.site.com.br/proxpagina.php' class='style1 style2' style='text-decoration:none'>
              <input type='button' name='Voltar' value='Voltar' onclick='location.href = 'http://www.site.com.br/paganterior.php';' title='Clique aqui caso queira retornar e corrigir algum dado.' />
            </a></strong></div></th>
            <th width='7%' scope='col'><div align='right'></div></th>
            <th width='39%' scope='col'> <div align='left'></div></th>
            <th width='8%' scope='col'> <div align='left'> </div></th>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </form></tr>
</table>
</body>
</html>



"} else {
	echo "Acesso não autenticado!";
}


?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

tenta agora:

 

 

<?
session_start();
$_SESSION['Nome']=$_POST['Nome'];
$_SESSION['DiaDataNascimento']=$_POST['DiaDataNascimento'];
$_SESSION['MesDataNascimento']=$_POST['MesDataNascimento'];
$_SESSION['AnoDataNascimento']=$_POST['AnoDataNascimento'];
$_SESSION['login']=$_POST['login'];

if (isset($_SESSION['login'])){
        //echo 

print "

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title></title>
<style type='text/css'>
  body {background-color: #ffffff;}
  .style17 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
</style>
</head>

<body>
<table width='100%' border='0' align='center'>
  <tr><form method=post action=proxpagina.php>
    <td bordercolor='#c19f62' scope='col'><table width='100%' border='0' cellpadding='0' cellspacing='0'>
      <tr>
        <th colspan='3' scope='col'><div align='left'><span class='style22'>Dados</span></div></th>
      </tr>
      <tr>
        <td width='39%'><div align='right' class='style17'>Nome</div></td>
        <td width='1%'></td>
        <td width='60%'><div align='left'><span class='style17'>";
           if (isset("".$_SESSION['Nome']."")){echo '</b><b>' "".$_SESSION['Nome']."";} 
		   print "
        </span></div></td>
      </tr>
      <tr bgcolor='f6efd2'>
        <td><div align='right' class='style17'>Data Nascimento </div></td>
        <td><span class='style16'></span></td>
        <td><div align='left'><span class='style17'>";

            if (isset("".$_SESSION['DiaDataNascimento']."")){$DiaDN=$_SESSION['DiaDataNascimento'];}
            if (isset($_SESSION['MesDataNascimento'])){$MesDN=$_SESSION['MesDataNascimento'];}
            if (isset($_SESSION['AnoDataNascimento'])){$AnoDN=$_SESSION['AnoDataNascimento'];}
                print "
        </span></div></td>
      </tr>
      <tr>
        <td colspan='3'><table width='100%'>
          <tr>
            <th width='8%' scope='col'> </th>
            <th width='38%' scope='col'><div align='right'><strong><a href='http://www.site.com.br/proxpagina.php' class='style1 style2' style='text-decoration:none'>
              <input type='button' name='Voltar' value='Voltar' onclick='location.href = 'http://www.site.com.br/paganterior.php';' title='Clique aqui caso queira retornar e corrigir algum dado.' />
            </a></strong></div></th>
            <th width='7%' scope='col'><div align='right'></div></th>
            <th width='39%' scope='col'> <div align='left'></div></th>
            <th width='8%' scope='col'> <div align='left'> </div></th>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </form></tr>
</table>
</body>
</html>



"} else {
        echo "Acesso não autenticado!";
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Rodrigo, deu pau agora nessa linha:

 

if (isset("".$_SESSION['Nome']."")){echo '</b><b>' "".$_SESSION['Nome']."";}

 

Parse error: syntax error, unexpected '"', expecting ',' or ';' in /home/site/www/pag.php on line 37

 

mantendo a linha original

if (isset(".$_SESSION['Nome'].")){echo '</b><b>' " . $_SESSION['Nome'].";} ?>

 

ele volta a dar pau a partir da linha:

 

if (isset("".$_SESSION['DiaDataNascimento']."")){$DiaDN=$_SESSION['DiaDataNascimento'];}

 

erro apresentado:

 

Parse error: syntax error, unexpected '"', expecting ',' or ';' in /home/site/www/pag.php on line 44

 

 

Observando o código você colocou mais aspas no começo e no fim da condição do isset mas após manteve a variavel $DiaDN sem nenhum "tratamento"... seria por ai o erro?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Isto aqui está errado..

 

if (isset("".$_SESSION['Nome']."")){echo '</b><b>' "".$_SESSION['Nome']."";} 

Não se coloca aspas na variável dentro da função.

 

if (isset($_SESSION['Nome']))
{
echo '</b><b>'.$_SESSION['Nome'];
} 

Corrija isto nas outras partes do seu código que deve funcionar.

 

Carlos Eduardo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Carlos, valeu a força.

 

Resolvi a bronca alterando um pouco a sua dica.

 


<?
session_start();
$_SESSION['Nome']=$_POST['Nome'];
$_SESSION['DiaDataNascimento']=$_POST['DiaDataNascimento'];
$_SESSION['MesDataNascimento']=$_POST['MesDataNascimento'];
$_SESSION['AnoDataNascimento']=$_POST['AnoDataNascimento'];
$_SESSION['login']=$_POST['login'];

if (isset($_SESSION['login']))
{

print "

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title></title>
<style type='text/css'>
 body {background-color: #ffffff;}
 .style17 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
</style>
</head>

<body>
<table width='100%' border='0' align='center'>
 <tr><form method=post action=proxpagina.php>
   <td bordercolor='#c19f62' scope='col'><table width='100%' border='0' cellpadding='0' cellspacing='0'>
     <tr>
       <th colspan='3' scope='col'><div align='left'><span class='style22'>Dados</span></div></th>
     </tr>
     <tr>
       <td width='39%' bgcolor='#FFFFFF'><div align='right' class='style17'>Nome</div></td>
       <td width='1%' bgcolor='#FFFFFF'></td>
       <td width='60%' bgcolor='#FFFFFF'><div align='left'><span class='style17'>
         <? if (isset(".$_SESSION['Nome'].")){echo '</b><b>' " . $_SESSION['Nome'].";} ?>
       </span></div></td>
     </tr>
     <tr bgcolor='f6efd2'>
       <td bgcolor='#FFFFFF'><div align='right' class='style17'>Data Nascimento </div></td>
       <td bgcolor='#FFFFFF'><span class='style16'></span></td>
       <td bgcolor='#FFFFFF'><div align='left'><span class='style17'>
         <?
			 if (isset(".$_SESSION['DiaDataNascimento'].")){'$DiaDN'=".$_SESSION['DiaDataNascimento'].";}
                if (isset(".$_SESSION['MesDataNascimento'].")){'$MesDN'=".$_SESSION['MesDataNascimento'].";}
                if (isset(".$_SESSION['AnoDataNascimento'].")){'$AnoDN'=".$_SESSION['AnoDataNascimento'].";}
               ?>
       </span></div></td>
     </tr>
     <tr>
       <td colspan='3' bgcolor='#FFFFFF'><table width='100%'>
         <tr>
           <th width='8%' scope='col'> </th>
           <th width='38%' scope='col'><div align='right'><strong><a href='http://www.site.com.br/proxpagina.php' class='style1 style2' style='text-decoration:none'>
             <input type='button' name='Voltar' value='Voltar' onclick='location.href = 'http://www.site.com.br/paganterior.php';' title='Clique aqui caso queira retornar e corrigir algum dado.' />
           </a></strong></div></th>
           <th width='7%' scope='col'><div align='right'></div></th>
           <th width='39%' scope='col'> <div align='left'></div></th>
           <th width='8%' scope='col'> <div align='left'> </div></th>
         </tr>
       </table></td>
     </tr>
   </table></td>
 </form></tr>
</table>
</body>
</html>



";}
else {
echo "Acesso não autenticado!";
}


?>


 

Mais uma vez, muito obrigado pela atenção! Pode fechar o tópico.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.