Write haof XML files: Marcelo Sosa
(
lmskako@yahoo.com.ar)
Fecha: mié 02 nov 2005 - 20:37:25 CET
Perdon, va corregido...
--------------------------------------------------------------------
config.php
--------------------------------------------------------------------
<?php
define("DB_HOST", "localhost");
define("DB_NAME", "nombre_db");
define("DB_USER", "usuario");
define("DB_PASS", "password");
define("DB_TIPO", "MySQL");
?>
--------------------------------------------------------------------
class_db.php
--------------------------------------------------------------------
<?php require_once("config.php");?>
<?php
class DBs{
var $host;
var $user;
var $pass;
var $db_name;
var $db_tipo;
var $id_con = 0;
var $id_q = 0;
//********* inicializo las
variables **************
function DBs(){
$this->host
= DB_HOST;
$this->user
= DB_USER;
$this->pass
= DB_PASS;
$this->db_name
= DB_NAME;
if(DB_TIPO
!= NULL && DB_TIPO != ''){
$this->db_tipo
= DB_TIPO;
}else{
$this->db_tipo
= "MySQL";
}
}
//************** conectar a la
BD ***************
function conectar(){
switch($this->db_tipo){
case
"MySQL":
$this->id_con
=
mysql_connect($this->host,$this->user,$this->pass);
if($this->id_con){
mysql_select_db($this->db_name,
$this->id_con);
}
break;
case
"MSSQL":
$this->id_con
=
mssql_connect($this->host,$this->user,$this->pass);
if($this->id_con){
mssql_select_db($this->db_name,
$this->id_con);
}
break;
}
return
$this->id_con;
}
//***************** aqui hago
las consultas *************
function consultar($SQL =
""){
switch($this->db_tipo){
case
"MySQL":
$this->id_q
= mysql_query($SQL, $this->id_con);
break;
case
"MSSQL":
$this->id_q
= mssql_query($SQL, $this->id_con);
break;
}
return
$this->id_q;
}
//************
cierro la conexion ********************
function
close(){
switch($this->db_tipo){
case
"MySQL":
mysql_close($this->id_con);
break;
case
"MSSQL":
mssql_close($this->id_con);
break;
}
}
}
?>
--------------------------------------------------------------------
index.php
--------------------------------------------------------------------
<?php require_once('includes/class_db.php');?>
<?php
if(isset($_POST['send'])){
$nombre = ($_POST['txtNom'] !=
'') ? "'".$_POST['txtNom']."'" : "NULL";
$SQL = "INSERT INTO
idiomas(nombre) VALUES(".$nombre.");";
$res = new DBs();
$res->conectar();
$r =
$res->consultar($SQL);
$res->close();
if(!$r){
echo
"tiro falso!!!";
die;
}
echo "\$r=".$r;die;
header('Location:
'.$_SERVER['PHP_SELF'].'?e=0');
exit();
}
?>
<html>
<body>
<form name="form1"
id="form1" method="post" action="<?php echo
$_SERVER['PHP_SELF'];?>">
<input
name="txtNom" type="text" id="txtNom" />
<input
type="submit" name="Submit" value="Submit" />
<input
name="send" type="hidden" id="send" value="1" />
</form>
</body>
</html>
--------------------------------------------------------------------------------
> La clase que enviaste no tiene un
método ::close() --y me marca un
> warning de "propiedad no definida"
con ::$id_query (@65)
>
> Marcelo Sosa wrote:
>
>> Bueno, desde ya agradecido por
sus ayudas...
>> Y les paso lo que corresponde
a este problema asi lo vemos todos.
>
>
[···]
>
>> bueno, estas son las paginas
en cuestion que dan el problema, no las
>> numere asi, si desean
reproducir esto no los moleste.
>
> [···]
-- PHP Spanish Localization Talk Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Este archivo fue generado por hypermail 2.1.7 : sáb 18 mar 2006 - 18:23:40 CET