Hi monkers.
Im facing a strange issue, i have done a piece of code to get connected to a db, select some values passed from a HTML form and use this value has a value of the query.
MY db its on local and im using DBD::Mysql driver to get connected to the database. When i do the query using the file connection.cgi (with a select : select * from db) it returns me a lot of blank results, falling in a infinite loop of dead that kill my machine. I dunno what da hell im going bad, my table only have 2 records and perl see that 2 records and then populate my HTML-results page with
BreakLines....
Updated: i doesnt saw this perl script flush all the data of the query to ha hash, this make my computer hangs up, but if i print the output to the HTML, it prints me breaklines to the end of times.
This its mi code
#!"C:\xampp\perl\bin\perl.exe"
use CGI qw(:all);
use DBI;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
#Datos de la conexión
$db="db_jo151";
$host="localhost";
$port="3306";
$userid="db4_fabrik";
$passwd="secret!";
#Recibimos los datos del formulario
@campos = split(/\&/,$ENV{'QUERY_STRING'});
foreach $valor (@campos) {
($nombre_variable, $dato) = split(/=/,$valor);
print "$nombre_variable = $dato\n";
}
# Realizamos la conexión a la base de datos
$dbh = DBI->connect("DBI:mysql:database=$db;host=$host", $userid, $pas
+swd);
#Sentencia SQL
$query = qq(select * from joomladb_estados where est_matricula like '%
+$dato');
print "<h2>la query es -->$query</h2>";
# Primero hay que "preparar" el query
$sth = $dbh->prepare($query);
# Ejecutamos el query
$sth->execute or print "Ha fallado la consulta query";
#indicamos que vamos a imprimir HTML
print "<html><head><title>Consulta de Estado</title></head>\n";
print "<body>\n";
print "Variables -> $ENV{'QUERY_STRING'}\n";
# Recorremos los resultados obtenidos de la base de datos
%almacen;
while (($id, $fecha, $matricula) = $sth->fetchrow_array) {
$almacen{$matricula}{'fecha_entrada'}=$fecha;
$almacen{$matricula}{'estado'}=$estado;
}
print"</body></html>";
# Indicamos que hemos acabado y desconectamos
$sth->finish();
$dbh->disconnect;
exit 0;