Jump to content


Photo

Erro Php 5


  • Faça o login para participar
1 reply to this topic

#1 BJ-AMARAL

BJ-AMARAL

    12 Horas

  • Usuários
  • 136 posts
  • Sexo:Não informado
  • Interesses:"Tudo é pouco na vida"

Posted 29/05/2007, 19:18

Galera funciono, mudei o nome da xml e funciono.


----------------------------------------------------------------------------------------------

Olá galera tudo blz?

Bom tou começando a mecher com PHP5 OOP mais ta dificil, estou fazendo um sistema de login os codigos esta postados, não tenho nem ideia do que pode ser, e outra ele so funciona de vez enquando.

o erro que perciste é esse

"Fatal error: Call to undefined function mysql_connect() in C:\Arquivos de programas\EasyPHP 2.0b1\www\site_admin\db\BancodeDados.class.php on line 17
"
arquivo BancodeDados.class.php
<?php
class BancodeDados {
private $host;
private $username;
private $password;
private $connection;
private $squema;
public function BancodeDados($resource) {
$xml = simplexml_load_file($resource);
$this->host = $xml->sessionfactory->host;
$this->username = $xml->sessionfactory->username;
$this->password = $xml->sessionfactory->password;
$this->squema = $xml->sessionfactory->database;
}
public function conecta() {

$this->connection = mysql_connect($this->host, $this->username,$this->password);
mysql_select_db($this->squema,$this->connection);

return $this->connection;
}

public function desconecta() {
mysql_close($this->connection);
}
public function updateSQL($sql) {
$r = mysql_query($sql,$this->connection);
if($r == 0) {
return false;
} else {
return true;
}
}
public function executaSQL($sql) {
$retorno = mysql_query($sql,$this->connection);
return $retorno;
}
public function iniciarTransacao() {
$this->executaSQL("begin");
}
public function efetivarTransacao() {
$this->executaSQL("commit");
}
public function desfazerTransacao() {
$this->executaSQL("rollback");
}
} 

?>

arquivo index.php

<?php 
include("config_geral.php");
require_once("db/BancodeDados.class.php");

function autentica($tbl, $login, $senha)
	{
 #CHAMA O MÉTODO DE CONEXÃO COM O BANCO DE DADOS.
 $banco = new BancodeDados("db/conn.xml");
 $banco->conecta();
 #VERIFICA SE EXISTE ALGUM LOGIN CADASTRADO NO BANCO COM O INFOMRADO.
 $query = mysql_query("select senha_user, login_user from $tbl WHERE login_user='".sha1($login)."' AND senha_user='".sha1($senha)."'  ") or die("ERRO4: ".mysql_error());  
	 #VERIFICA SE A SENHA INFORMADA É VÁLIDA.
	 if(mysql_num_rows($query)>0):
	 $this->msg = "LOGADO COM SUCESSO";
	 //header("location: ?now=cadastrar&msg=OPERAÇÃO REALIZADA COM SUCESSO"); 
	 else:
	 $this->msg = "SENHA INVÁLIDA";	  
	 endif;

 return $this->msg;
 }

#VERIFICA A ENTRADA DOS CAMPOS.
if(!empty($_POST['login']) && !empty($_POST['senha']) ):
	#FAZ A AUTENTICAÇÃO.
	autentica("usuario",$_POST['login'],$_POST['senha']);
endif;
?>

<!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>. :: <?php echo $titulo_admin; ?> - Login :: .</title>
<style type="text/css">
body {
	background-color: #A5ADB0;
}
</style>
<link href="img_admin/admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
	<!-- fwtable fwsrc="tela login admin.png" fwbase="login.jpg" fwstyle="Dreamweaver" fwdocid = "1915283636" fwnested="0" -->
	<tr>
	  <td><img src="img_admin/spacer.gif" width="158" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="10" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="220" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="128" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="24" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="141" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="24" height="1" border="0" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="1" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="7"><img name="login_r1_c1" src="img_admin/login_r1_c1.jpg" width="705" height="20" border="0" id="login_r1_c1" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="20" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2" colspan="3"><img name="login_r2_c1" src="img_admin/login_r2_c1.jpg" width="388" height="89" border="0" id="login_r2_c1" alt="" /></td>
	  <td colspan="3"><img name="login_r2_c4" src="img_admin/login_r2_c4.jpg" width="293" height="72" border="0" id="login_r2_c4" alt="" /></td>
	  <td rowspan="6"><img name="login_r2_c7" src="img_admin/login_r2_c7.jpg" width="24" height="385" border="0" id="login_r2_c7" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="72" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="3"><img name="login_r3_c4" src="img_admin/login_r3_c4.jpg" width="293" height="17" border="0" id="login_r3_c4" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="17" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2" colspan="2"><img name="login_r4_c1" src="img_admin/login_r4_c1.jpg" width="168" height="90" border="0" id="login_r4_c1" alt="" /></td>
	  <td colspan="2" background="img_admin/login_r4_c3.jpg"><img name="login_r4_c3" src="img_admin/user_incorreto.jpg" width="348" height="74" border="0" id="login_r4_c3" alt="" /></td>
	  <td rowspan="2" colspan="2"><img name="login_r4_c5" src="img_admin/login_r4_c5.jpg" width="165" height="90" border="0" id="login_r4_c5" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="74" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="2"><img name="login_r5_c3" src="img_admin/login_r5_c3.jpg" width="348" height="16" border="0" id="login_r5_c3" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="16" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td rowspan="2"><img src="img_admin/login_r6_c1.jpg" alt="" name="login_r6_c1" width="158" height="206" border="0" usemap="#login_r6_c1MapMap" id="login_r6_c1" /></td>
	  <td colspan="4" background="img_admin/login_r6_c2.jpg"><table width="100%" height="104" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td width="12%"> </td>
			<td width="23%"><div align="right" class="style1">Usuário:</div></td>
			<td width="65%"><input name="login" type="text" class="form_login" id="login" size="25" /></td>
		  </tr>
		  <tr>
			<td> </td>
			<td><div align="right" class="style1">Senha:</div></td>
			<td><input name="senha" type="text" class="form_login" id="senha" size="25" /></td>
		  </tr>
		  <tr>
			<td> </td>
			<td> </td>
			<td><input name="imageField" type="image" src="img_admin/entrar.jpg" alt="Logar ao sistema" /></td>
		  </tr>
	  </table></td>
	  <td rowspan="2"><img name="login_r6_c6" src="img_admin/login_r6_c6.jpg" width="141" height="206" border="0" id="login_r6_c6" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="149" border="0" alt="" /></td>
	</tr>
	<tr>
	  <td colspan="4"><img name="login_r7_c2" src="img_admin/login_r7_c2.jpg" width="382" height="57" border="0" id="login_r7_c2" alt="" /></td>
	  <td><img src="img_admin/spacer.gif" width="1" height="57" border="0" alt="" /></td>
	</tr>
  </table>
  <map name="login_r6_c1MapMap" id="login_r6_c1MapMap">
	<area shape="rect" coords="14,138,65,181" href="java script:history.back(-1);" alt="Voltar" />
  </map>
</form>
<map name="login_r6_c1Map" id="login_r6_c1Map">
<area shape="rect" coords="14,138,65,181" href="java script:history.back(-1);" />
</map></body>
</html>

arquivo conn.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
<sessionfactory>
<host>localhost</host>
<username>root</username>
<password></password>
<database>usuarios_admin</database>
</sessionfactory>
</xml>

Bom galera, espero um ajuda de vocês.

Obrigado pela atenção,

Atenciosamente,
Pedro Amaral

Edição feita por: BJ-AMARAL, 29/05/2007, 20:59.

<< Utilidades >>
- PHP
- HTML
- XHTML
- XML
- XSL
- DTD
- JAVA SCRIPT
- MYSQL
- COREL
- FIREWORKS
- DREAMWEAVER
- FLASH
- FIREWALL
- DELPHI

<< fim >>

#2 savior

savior

    Campanha [codebox], use ou morra :D

  • Usuários
  • 1229 posts
  • Sexo:Masculino
  • Localidade:Curitiba, PR - Brasil
  • Interesses:Na vida ;P

Posted 30/05/2007, 14:30

<?php
phpinfo();
?>

Verifica se a lib do mysql foi carregada, senão tem que adicionar ela no .ini do seu php

Edição feita por: savior, 30/05/2007, 14:30.

[lastfm] [blog]

Campanha codebox: use-a ou morra!
bfmaster_duran[at]yahoo.com.br





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq