Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # PERL MODULES WE WILL BE USING
- use DBI;
- use DBD::mysql;
- # HTTP HEADER
- print "Content-type: text/html \n\n";
- # CONFIG VARIABLES
- $platform = "mysql";
- $host = "localhost";
- $database = "datachk";
- $tablename = "usuario";
- $user = "root";
- $password = "root";
- # DATA SOURCE NAME
- $dsn = "dbi:mysql:$database:localhost:3306";
- # PERL DBI CONNECT
- $connect = DBI->connect($dsn, $user, $password);
- # PREPARE THE QUERY
- $query = "SELECT * FROM usuario ORDER BY cpf";
- $query_handle = $connect->prepare($query);
- # EXECUTE THE QUERY
- $query_handle->execute();
- # BIND TABLE COLUMNS TO VARIABLES
- $query_handle->bind_columns(undef, \$cpf, \$nome, \$nivel, \$login, \$senha);
- # LOOP THROUGH RESULTS
- while($query_handle->fetch()) {
- print "$cpf, $nome, $nivel, $login <br />";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement