Sombrerero_loco has asked for the wisdom of the Perl Monks concerning the following question:
#!"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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with mysql query using DBI::Mysql
by arc_of_descent (Hermit) on May 25, 2009 at 10:48 UTC | |
|
Re: Problem with mysql query using DBI::Mysql
by FloydATC (Deacon) on May 25, 2009 at 10:00 UTC | |
|
Re: Problem with mysql query using DBI::Mysql
by CountZero (Bishop) on May 25, 2009 at 22:31 UTC | |
|
Re: Problem with mysql query using DBI::Mysql
by graff (Chancellor) on May 25, 2009 at 23:41 UTC |