conexão e busca de dados php

0 respostas
adonielcarvalho

Boa tarde galera estou com um probleminha sou iniciante em php, presciso buscar alguns dados no banco mais esta dando erro, nao busca os dados e o navegador sempre trava,
OBS: o campo host nao pois por razoes de segurança o password também.

<?php

$host="";
$banco="db2";
$user="root";
$password="";


$conexao = mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db($banco, $conexao);

//criando a query 

$query = sprintf("select DT_LIB_CRD_CTR, NR_CTR_CVN, CD_LNCD, valor_desembolso, tot_credito_novo from desembolso");

$dados = mysql_query($query, $conexao) or die(mysql_error());

$linha = mysql_fetch_assoc($dados);

$total = mysql_num_rows($dados); 

?>

<html>
<head>
<meta charset="utf-8">
<title>Valor_liquido</title>
</head>

<body>

<img src="../../../Tomcat6/webapps/diemp/images/nav-bg.png"  alt="Desembolso Liquido" width="1313" height="133" id="imgae" title="Desembolso Liquido"/>

<table width="1320" height="89" border="1">
  <tr>
  <th width="63" height="42" align="center" valign="bottom" bgcolor="#333333" style="color: #CCC" scope="col">Data</th>
    <th width="63" height="42" align="center" valign="bottom" bgcolor="#333333" style="color: #CCC" scope="col">Número<br>Convenio</th>
    <th width="63" valign="bottom" bgcolor="#333333" style="color: #CCC" scope="col"> Convenio<br>Linha</th>
    <th width="130" valign="bottom" bgcolor="#333333" style="color: #CCC" scope="col">Valor<br>Desembolso</th>
    <th width="138" valign="bottom" bgcolor="#333333" style="color: #CCC" scope="col">Total Crédito<br>Novo</th>
    
	
  </tr>
  	
	<?php  
if($total>0){ 
 do{ 
?>
  <tr>
  <td>
   <p><?=$linha['DT_LIB_CRD_CTR']?></p>
  
  </td>
    <td>
    <p><?=$linha['NR_CTR_CVN']?></p>
    </td>
    <td>
    <p><?=$linha['CD_LNCD']?></p>
    </td>
    <td>
    <p><?=$linha['valor_desembolso']?></p>
    </td>
    <td>
    <p><?=$linha['tot_credito_novo']?></p>
    </td>
  </tr>
 

<?php
} while ($linha = mysql_fetch_assoc($dados));
 mysql_free_result($dados);
} 
?>

</table>
<?php

mysql_close();

?>
</body>
</html>

se alguém poder me ajudar

Criado 5 de novembro de 2015
Respostas 0
Participantes 1