Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Banco de dados não retorna


Guest --tullius --

Pergunta

Guest --tullius --

Olá, esta semana troquei o servidor de hospedagem do site www.portalcipo.com.br, o antigo servidor era php4 e o novo e php5, o site todo e sobe consulta ao db, ele ate conecta ao banco de dados, so que não retorna nada, o site so aparece o index o resto não funciona, eu tenho que fazer alguma alteração no codigo por mudar do php4 pro php5?

grato.

Link para o comentário
Compartilhar em outros sites

10 respostass a esta questão

Posts Recomendados

  • 0

Se por acaso o seu site dependa de register_globals ativado e no novo servidor ele estiver desativado, isso já trás um problemão (mas dá pra contornar), mas não se relacionaria diretamente a questão do banco de dados (a menos que você passe tudo por querystring e realmente precisasse de register_globals), coloque p código uma das páginas que não funciona pra gente dar uma olhada.

Link para o comentário
Compartilhar em outros sites

  • 0

para conectar

<?php

$dbname="********";

$usuario="*******";

$senha="********";

$conexao = mysql_connect("localhost",$usuario,$senha) or die ("Não foi possivel conectar ao servidor ");

$db = mysql_select_db("$dbname", $conexao) or die ("Não foi possivel conectar ao banco de dados");

?>

parte do arquivo menu, na hora que clica no link ele não carrega a pagina, ou seja não da retorno do db

<?php

include"abreconexao.inc";

$sql = "select * FROM tb_menu WHERE cod_menu = 'serra' ORDER BY ordem asc ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs)) {

$categoria = $linha['categoria'];

$link = $linha['link'];

$nome = $linha['nome'];

?>

<TR>

<TD width=100%" bgColor=#CCCCCC> </TD>

</TR>

<TR>

<TD width="100%"

height=15 bgColor=#999999 class="linkinterior" onmouseover="mOvr(this,'#FF9900');"

onmouseout="mOut(this,'#999999');">&nbsp;<IMG height=9 src="arquivos/barra%20menu/setica.gif" border=0 width="8">&nbsp; <A

href="<?php echo $link ;?><?php echo $categoria ;?>"><?php echo $nome ;?></A></TD>

</TR>

<TD width="100%" bgColor=#000000></TD>

</TR>

<?php

}

?>

<TR>

<TD width="100%" bgColor=#999999></TD>

</TR>

<TR>

<TD width="100%"

height=18 bgColor=#666666 class="linkinterior"

><div align="left"><strong>&nbsp;<font color="#CCCCCC">H</font></strong><font color="#CCCCCC">ospedagem</font></div>

</TD>

</TR>

<TD width="100%" bgColor=#333333></TD>

<?php

$sql = "select * FROM tb_menu WHERE cod_menu = 'hospedagem' ORDER BY ordem asc ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta13");

while ($linha = mysql_fetch_array($rs)) {

$link = $linha['link];

$nome = $linha['nome'];

$categoria = $linha['categoria'];

?>

<TR>

<TD width=100%" bgColor=#CCCCCC></TD>

</TR>

<TR>

<TD width="100%"

height=15 bgColor=#999999 onmouseover="mOvr(this,'#FF9900');"

onmouseout="mOut(this,'#999999');"><span class="linkinterior">&nbsp;<IMG height=9

src="arquivos/barra%20menu/setica.gif"

width=8 border=0>&nbsp;</span> <A

href="<?php echo $link ;?><?php echo $categoria ;?>"><?php echo $nome ;?></A></TD>

</TR>

<TD width="100%" bgColor=#000000></TD>

</TR>

<?php

}

?>

<TR>

<TD width="100%" bgColor=#999999></TD>

</TR>

<TR>

<TD width="100%"

height=18 bgColor=#666666 class="linkinterior"

><div align="left"><strong>&nbsp;<font color="#CCCCCC">S</font></strong><font color="#CCCCCC">aib&aacute; Mais</font></div>

</TD>

</TR>

<TD width="100%" bgColor=#000000></TD>

<?php

$sql = "select * FROM tb_menu WHERE cod_menu = 'saibamais' ORDER BY ordem asc ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta14");

while ($linha = mysql_fetch_array($rs)) {

$link = $linha['link];

$nome = $linha['nome'];

$categoria = $linha['categoria'];

?>

<TR>

<TD width="100%" bgColor=#CCCCCC></TD>

</TR>

<TR>

<TD width="100%"

height=15 bgColor=#999999 class="linkinterior" onmouseover="mOvr(this,'#FF9900');"

onmouseout="mOut(this,'#999999');">&nbsp;<IMG height=9 src="arquivos/barra%20menu/setica.gif" width=8 border=0>&nbsp; <A

href="<?php echo $link ;?><?php echo $categoria ;?>"><?php echo $nome ;?></A></TD>

</TR>

<TD width="100%" bgColor=#000000></TD>

</TR>

<?php

}

?>

Link para o comentário
Compartilhar em outros sites

  • 0

hospedagem

<?php include "cores.php"; ?>

<div align="left"> <?php include "cima.php" ?>

<table width="779" height="85%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="0%" height="396"><img src="arquivos/barra%20menu/1.gif" width="2" height="100%"></td>

<td width="99%" valign="top"><table width="772" height="127%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="14%" height="400" valign="top">

<div align="left"><?php include "menu.php"; ?></div>

</td>

<td width="69%" valign="top"><p>

<?php

include "abreconexao.inc";

$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs))

$barra_inicial = $linha['barra_inicial'];

?>

<p>&nbsp;

<table width=99%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><div align="center"><img src="<?php echo $barra_inicial; ?>" width="490" height="21"></div></td>

</tr>

</table>

<?php

include "abreconexao.inc";

$sql = "select * FROM tb_hospedagem WHERE categoria = '$cod_cat' ORDER BY id asc ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs)) {

$nome_hospedagem = $linha['nome_hospedagem];

$foto_link = $linha['foto_link'];

$descri = $linha['descri'];

$nome_cliente = $linha['nome_cliente'];

$categoria = $linha['categoria'];

?>

<p>&nbsp;</p><table width=100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="174"><table width="98%" height="152" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="45%" height="152"><div align="center"><img src="<?php echo $foto_link; ?>" width="207" height="143"></div></td>

<td width="55%"><table width="100%" height="152" border="0" cellpadding="0" cellspacing="0">

<tr>

<td height="18" bgcolor="#CCCCCC"><div align="center"><strong><?php echo $nome_cliente; ?></strong></div></td>

</tr>

<tr>

<td height="114"><font size="1"><?php echo $descri; ?></font></td>

</tr>

<tr>

<td height="19" bordercolor="#666666" bgcolor="#CCCCCC"><div align="center"><a href="mais.php?cod_cat=<?php echo $categoria; ?>&detali=<?php echo $nome_hospedagem; ?>" target="_blank">Clique

aqui para conhecer melhor.</a></div></td>

</tr>

</table></td>

</tr>

</table>

<hr width="98%" size="1" color="#000000"></td>

</tr>

</table>

<?php

}

mysql_free_result($rs);

mysql_close($conexao);

?>

<p>&nbsp; </p></td>

<td width="17%" valign="top"><?php include "menues.php"; ?></td>

</tr>

</table></td>

<td width="1%"><div align="right">

<p><img src="arquivos/barra%20menu/3.gif" width="3" height="101%"></p>

</div></td>

</tr>

</table>

<? include "rodape.php" ?>

</div>

saiba mais

<?php include "cores.php"; ?>

<div align="left"> <?php include "cima.php" ?>

<table width="779" height="85%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="0%" height="396"><img src="arquivos/barra%20menu/1.gif" width="2" height="100%"></td>

<td width="99%" valign="top"><table width="772" height="127%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="14%" height="400" valign="top">

<div align="left"><?php include "menu.php"; ?></div>

</td>

<td width="69%" valign="top"><p>

<?php

include "abreconexao.inc";

$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs))

$barra_inicial = $linha['barra_inicial];

?>

<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><div align="center"><img src="<?php echo $barra_inicial ?>" width="490" height="21"></div></td>

</tr>

</table><?php

include "abreconexao.inc";

$sql = "select * FROM tb_saiba WHERE categoria = '$cod_cat' ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs))

$html = $linha['html'];

?>

<p>&nbsp;</p>

<table width=98%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><?php echo $html ?> </td>

</tr>

</table>

<p>&nbsp;</p>

</p></td>

<td width="17%" valign="top"><?php include "menues.php"; ?></td>

</tr>

</table></td>

<td width="1%"><div align="right">

<p><img src="arquivos/barra%20menu/3.gif" width="3" height="101%"></p>

</div></td>

</tr>

</table>

<?php include "rodape.php" ?>

</div>

serra

<?php include "cores.php"; ?>

<div align="left"> <?php include "cima.php" ?>

<table width="779" height="85%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="0%" height="396"><img src="arquivos/barra%20menu/1.gif" width="2" height="100%"></td>

<td width="99%" valign="top"><table width="772" height="127%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="14%" height="400" valign="top">

<div align="left"><?php include "menu.php"; ?></div>

</td>

<td width="69%" valign="top"><p>

<?php

include "abreconexao.inc";

$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs))

$barra_inicial = $linha['barra_inicial];

?>

<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><div align="center"><img src="<?php echo $barra_inicial ?>" width="490" height="21"></div></td>

</tr>

</table><?php

include "abreconexao.inc";

$sql = "select * FROM tb_serra WHERE categoria = '$cod_cat' ";

$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta12");

while ($linha = mysql_fetch_array($rs))

$html = $linha['html'];

?>

<p>&nbsp;</p>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><?php echo $html ?> </td>

</tr>

</table>

<p>&nbsp;</p>

</p></td>

<td width="17%" valign="top"><?php include "menues.php"; ?></td>

</tr>

</table></td>

<td width="1%"><div align="right">

<p><img src="arquivos/barra%20menu/3.gif" width="3" height="101%"></p>

</div></td>

</tr>

</table>

<?php include "rodape.php" ?>

</div>

Link para o comentário
Compartilhar em outros sites

  • 0

É... depende de register_globals...

Em todos os código altera disso:

include "abreconexao.inc";
$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";
Para isso
include "abreconexao.inc";
$cod_cat = mysql_real_escape_string($_GET['cod_cat']);
$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";

Link para o comentário
Compartilhar em outros sites

  • 0

Ele tá dizendo que a query tem algum erro, só que você tá mandando o or die se o mysql encontrar algum erro e ele não tá retornando nenhum erro... coloca o código como está atualmente (esse que tá dando erro). Outra coisa, você coloca os dados de conexão em arquivos .inc? E se o cara acessar o arquivo direto? Já pensou que ele vai ver tudo isso:

<?php
$dbname="port*******";
$usuario="port****";
$senha="tri*****";

$conexao = mysql_connect("localhost",$usuario,$senha) or die ("Não foi possivel conectar ao servidor ");
$db = mysql_select_db("$dbname", $conexao) or die ("Não foi possivel conectar ao banco de dados");
?>

Removi parte dos dados pra te evitar problemas...

Link para o comentário
Compartilhar em outros sites

  • 0

Mas eu pedi pra você altearar assim:

include "abreconexao.inc";
$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";
Para isso
include "abreconexao.inc";
$cod_cat = mysql_real_escape_string($_GET['cod_cat']);
$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";
Só isso... tá faltando a parte que executa a query:
$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta13");
E também ali no mysql_fetch_array($cod_cat) o correto é mysql_fetch_array($rs). Ou seja
include "abreconexao.php";
$cod_cat = mysql_real_escape_string($_GET['cod_cat']);
$sql = "select * FROM tb_barra WHERE categoria_barra = '$cod_cat' ";
$rs = mysql_query($sql, $conexao) or die ("Não foi possivel efetuar a consulta13");

while ($linha = mysql_fetch_array($rs))
$barra_inicial = $linha['barra_inicial'];

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...