Using perl Syntax Highlighting
#!/usr/bin/perl -w
package ConectarDB;
use strict;
use DBI;
# variables a editar
my $db_user = "xxxxxx";
my $db_pass = "1234";
my $host_name = "xxxxx";
my $db_name = "1234";
my $db_name2 = "1234";
my $db_name3 = "xxxxxx";
my $q_string = "DBI:mysql:host=$host_name;database=$db_name";
my $q_string2 = "DBI:mysql:host=$host_name;database=$db_name2";
my $q_string3 = "DBI:mysql:host=$host_name;database=$db_name3";
sub connect{
return (DBI->connect ($q_string, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
sub connect2{
return (DBI->connect ($q_string2, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
sub connect3{
return (DBI->connect ($q_string3, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
1;
package ConectarDB;
use strict;
use DBI;
# variables a editar
my $db_user = "xxxxxx";
my $db_pass = "1234";
my $host_name = "xxxxx";
my $db_name = "1234";
my $db_name2 = "1234";
my $db_name3 = "xxxxxx";
my $q_string = "DBI:mysql:host=$host_name;database=$db_name";
my $q_string2 = "DBI:mysql:host=$host_name;database=$db_name2";
my $q_string3 = "DBI:mysql:host=$host_name;database=$db_name3";
sub connect{
return (DBI->connect ($q_string, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
sub connect2{
return (DBI->connect ($q_string2, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
sub connect3{
return (DBI->connect ($q_string3, $db_user, $db_pass,
{PrintError => 0, RaiseError => 1}));
}
1;
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4
Más adelante se accede a la base de datos con el connect. Se actualiza un campo que sí funciona. Luego se conecta mediante connect2 y da fallos al modificar unos campos. ¿No es necesario desconectar y luego volver a conectar?, porque en el fichero éste no cierra la conexión hasta el final.
No tengo mucha idea de esto, tenerme paciencia.
gracias