Jump to content


Renato Neves

Member Since 15/04/2007
Offline Last Active 06/12/2010, 21:50
-----

Topics I've Started

Duvida Em Php

06/12/2010, 21:50

Esse código é de um form para cadastrar testemunhos e depois tem um select de alguns testemunhos cadastrados no banco porem preciso inverter e nao estou tendo exito da alguns erros muito estranhos, alguem poderia me ajudar:


Código original:


<?

foreach($_REQUEST as $ind=>$val)
{
	$$ind=$val;
}

if(isset($cad))
{
	$campos = objSql::camposTabela('tb_testemunhos');
	objSql::cadForm($campos,'tb_testemunhos');
	objSql::msg_box('Testemunho cadastrado com sucesso! Por favor aguarde a aprovação pelo Administrador.',"?pg=cad_ministerio");
}

?>
<!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>Untitled Document</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<table width="100%" border="0"  id="tit">
  <tr>
    <td><span>T</span>estemunhos</td>
  </tr>
</table>
<br />
<?
if($idT<>"T")
{
?>
<form name="frm1" method="post" action="">
  <table width="71%" border="0" align="center" cellpadding="3" cellspacing="0" class="txt_geral">
  <tr>
    <td colspan="2" class="outraNot">Deixe aqui seu Testemunho</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="6%">Titulo</td>
    <td width="94%"><label>
      <input name="titulo" type="text" class="campos_login" id="titulo" size="110" />
    </label></td>
  </tr>
  <tr>
    <td>Testemunho</td>
    <td><label>
    <textarea name="testemunho" cols="110" rows="5" class="campos_login" id="testemunho"></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Autor</td>
    <td><input name="responsavel" type="text" class="campos_login" id="responsavel" size="110" /></td>
  </tr>
  <tr>
    <td>E-mail</td>
    <td><input name="responsavel2" type="text" class="campos_login" id="responsavel2" size="110" /></td>
  </tr>
  <tr>
    <td>Telefone</td>
    <td><input name="ddd" type="text" class="campos_login" id="ddd" size="3" />
      <input name="telefone" type="text" class="campos_login" id="telefone" size="15" /></td>
  </tr>
  <tr>
    <td class="outraNot">&nbsp;</td>
    <td class="outraNot"><label>
      <input name="cad" type="submit" class="bt_login" id="cad" value="Enviar Testemunho" />
    </label></td>
  </tr>
</table>
  <br />
</form>
<?
}
else
{
?>
<table width="100%" border="0">
  <tr>
    <td align="center"><input name="cad2" type="submit" class="bt_login" id="cad2" value="Clique aqui e envie seu testemunho" onclick="window.location='?p=testemunhos'" /></td>
  </tr>
</table>

<br />
<?
}
if($idT<>"" && $idT<>"T")
{
	$sql.=" id_testemunho=$idT";
}
if($sql<>"")
{
$sql.=" and ";
}
$sql.=" id_status=1";
$sT = objSql::selecionar('tb_testemunhos',"*",$sql);
$dT = objSql::dados($sT);
$rT = objSql::linhas($sT);

if($rT>0 && $idT<>"T")
{
?>
<table width="95%" border="0" align="center" cellspacing="0" class="txt_geral">
  <tr>
    <td class="lineC"><span class="style1" style="text-transform:uppercase; font-size:18px">
      <?=$dT['titulo']?>
    f</span></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2"><?=$dT['testemunho']?></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2" class="lineC"><strong>Autor:</strong>      <? if($dT['responsavel']<>""){echo $dT['responsavel'];}else{echo "Não Informado!";}?></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" class="outraNot">Ultimos Testemunhos</td>
  </tr>
  <tr>
    <td align="left">
    
    <?
	$sUT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc",5);
	
	?>
    <table width="95%" border="0">
      <?
	  while($dUT=objSql::dados($sUT))
	  {
	  ?>
      <tr>
        <td><a href="?p=testemunhos&idT=<?=$dUT['id_testemunho']?>">[+] <?=$dUT['titulo']?> </a></td>
      </tr>
   	  <?
	  }
	  ?>	
    </table>
    
    
    </td>
  </tr>
  <tr>
    <td align="center"><a href="?p=testemunhos&idT=T"><strong>Ver Todos os Testemunhos</strong></a></td>
  </tr>
</table>
<?
}
?>

  <?

if($idT=='T')
{
	$sTT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc");
	$rTT = objSql::linhas($sTT);
	if($rTT>0)
	{
?>
<table width="95%" border="0" align="center" class="txt_geral">
 <tr>
    <td>Clique sobre os testemunhos para visualiz&aacute;-los</td>
  </tr>
  <?
  while($dTT=objSql::dados($sTT))
  {
  ?>
  
  <tr>
    <td bgcolor="#f5f5f5"><a href="?p=testemunhos&idT=<?=$dTT['id_testemunho']?>">- <?=$dTT['titulo']?></a></td>
  </tr>
  <?
  }
  ?>	
</table>
<?
	}
}
?>

<p>&nbsp;</p>
</body>
</html>




Código atual:

<?

foreach($_REQUEST as $ind=>$val)
{
	$$ind=$val;
}

if(isset($cad))
{
	$campos = objSql::camposTabela('tb_testemunhos');
	objSql::cadForm($campos,'tb_testemunhos');
	objSql::msg_box('Testemunho cadastrado com sucesso! Por favor aguarde a aprovação pelo Administrador.',"?pg=cad_ministerio");
}

?>
<!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>Untitled Document</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<table width="100%" border="0"  id="tit">
  <tr>
    <td><span>T</span>estemunhos</td>
  </tr>
</table>
<p>
  <?
}
if($idT<>"" && $idT<>"T")
{
	$sql.=" id_testemunho=$idT";
}
if($sql<>"")
{
$sql.=" and ";
}
$sql.=" id_status=1";
$sT = objSql::selecionar('tb_testemunhos',"*",$sql);
$dT = objSql::dados($sT);
$rT = objSql::linhas($sT);

if($rT>0 && $idT<>"T")
{
?>
</p>
<table width="95%" border="0" align="center" cellspacing="0" class="txt_geral">
  <tr>
    <td class="lineC"><span class="style1" style="text-transform:uppercase; font-size:18px">
      <?=$dT['titulo']?>
    </span></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2"><?=$dT['testemunho']?></td>
  </tr>
  <tr>
    <td bgcolor="#FEF2C2" class="lineC"><strong>Autor:</strong>
      <? if($dT['responsavel']<>""){echo $dT['responsavel'];}else{echo "N&atilde;o Informado!";}?></td>
  </tr>
  <tr>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" class="outraNot">Ultimos Testemunhos</td>
  </tr>
  <tr>
    <td align="left"><?
	$sUT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc",5);
	
	?>
      <table width="95%" border="0">
        <?
	  while($dUT=objSql::dados($sUT))
	  {
	  ?>
        <tr>
          <td><a href="?p=testemunhos&amp;idT=<?=$dUT['id_testemunho']?>">[+]
            <?=$dUT['titulo']?>
          </a></td>
        </tr>
        <?
	  }
	  ?>
      </table></td>
  </tr>
  <tr>
    <td align="center"><a href="?p=testemunhos&amp;idT=T"><strong>Ver Todos os Testemunhos</strong></a></td>
  </tr>
</table>
<?
}
?>
<?

if($idT=='T')
{
	$sTT = objSql::selecionar('tb_testemunhos',"*","id_status=1","id_testemunho desc");
	$rTT = objSql::linhas($sTT);
	if($rTT>0)
	{
?>
<table width="95%" border="0" align="center" class="txt_geral">
  <tr>
    <td>Clique sobre os testemunhos para visualiz&aacute;-los</td>
  </tr>
  <?
  while($dTT=objSql::dados($sTT))
  {
  ?>
  <tr>
    <td bgcolor="#f5f5f5"><a href="?p=testemunhos&amp;idT=<?=$dTT['id_testemunho']?>">-
      <?=$dTT['titulo']?>
    </a></td>
  </tr>
  <?
  }
  ?>
</table>
<p>
  <?
	}
}
?>
</p>
<p><br />
  <?
if($idT<>"T")
{
?>
</p>
<form name="frm1" method="post" action="">
  <table width="71%" border="0" align="center" cellpadding="3" cellspacing="0" class="txt_geral">
  <tr>
    <td colspan="2" class="outraNot">Deixe aqui seu Testemunho</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="6%">Titulo</td>
    <td width="94%"><label>
      <input name="titulo" type="text" class="campos_login" id="titulo" size="110" />
    </label></td>
  </tr>
  <tr>
    <td>Testemunho</td>
    <td><label>
    <textarea name="testemunho" cols="110" rows="5" class="campos_login" id="testemunho"></textarea>
    </label></td>
  </tr>
  <tr>
    <td>Autor</td>
    <td><input name="responsavel" type="text" class="campos_login" id="responsavel" size="110" /></td>
  </tr>
  <tr>
    <td>E-mail</td>
    <td><input name="responsavel2" type="text" class="campos_login" id="responsavel2" size="110" /></td>
  </tr>
  <tr>
    <td>Telefone</td>
    <td><input name="ddd" type="text" class="campos_login" id="ddd" size="3" />
      <input name="telefone" type="text" class="campos_login" id="telefone" size="15" /></td>
  </tr>
  <tr>
    <td class="outraNot">&nbsp;</td>
    <td class="outraNot"><label>
      <input name="cad" type="submit" class="bt_login" id="cad" value="Enviar Testemunho" />
    </label></td>
  </tr>
</table>
  <br />
</form>
<?
}
else
{
?>
<table width="100%" border="0">
  <tr>
    <td align="center"><input name="cad2" type="submit" class="bt_login" id="cad2" value="Clique aqui e envie seu testemunho" onclick="window.location='?p=testemunhos'" /></td>
  </tr>
</table>

<p><br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>


Erro Em Script

03/10/2010, 20:56

Estou desenvolvendo este script de acordo com tutorial q achei na net e estou recebendo a mensagem de erro " Fatal error: Using $this when not in object context in /home/rccosas/public_html/classes/classes.php " alguem poderia me ajudar com uma dica do que pode estar ocorrendo:


	function idForm()
	{
		return $this->idForm;
	}
	  function selecionar($tabela="",$campos='*',$condicao="",$order="",$limit="",$exibir="")
	{
		
		if($condicao<>"")
		{
			$cond = "where ".$condicao;
		}
		
		if($order <> "")
		{
			$order = "order by ".$order;
		}
		
		if($limit <>"")
		{
			$limitar = " limit ".$limit;
		}
		$sql = "select ".$campos." from ".$tabela." ".$cond." ".$order." ".$limitar;
		
		if($exibir<>"")
		{
			echo $sql;
		}
		$this->selecionar_valores = mysql_query($sql)or die(mysql_error());
		return $this->selecionar_valores;	
	
	}

IPB Skin By Virteq