-
-
Save anonymous/63d70344cfd370dd104f47328bc4f5c4 to your computer and use it in GitHub Desktop.
Consulta ao banco de dados...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function query_sql( $srv, $qry ) { | |
if( empty ( $srv ) ) { | |
echo "Especifique servidor, usuário e senha <br>"; | |
$srv = "0"; | |
echo " | |
function query_sql( \$srv, \$qry ) { | |
if( empty ( \$srv ) ) { | |
echo \"Especifique servidor, usuário e senha <br>\"; | |
\$srv = \"0\"; | |
echo \"reporte\"; } | |
\"; } "; } | |
else { | |
$srv_arr = explode ( " ", $srv, 3 ); | |
$hst = $srv_arr [0]; | |
$usr = $srv_arr [1]; | |
$snh = $srv_arr [2]; | |
echo "Testando \$hst, \$usr, \$snh: ". | |
$hst." ".$usr." ".$snh." <br><br>"; | |
$lnk = mysqli_connect ( $hst, $usr, $snh ); | |
if( !$lnk ) { die( 'Conexão inválida: <br><br>'. | |
mysql_connect_error() ); }; | |
echo "Conexão conectada com sucesso! <br><br>" | |
if( empty( $qry ) ) { echo "Query vazia!<br><br>"; } | |
else { | |
$res = mysql_query( $qry ); | |
if( empty( $res ) ) { | |
echo "Testando \$res: vazia!<br><br>"; } | |
else { echo "Testando \$res: ".$res; } | |
if( !$res ) { | |
die( 'Query inválida! - mysql_error(): '. | |
mysql_error() ); } else { return $res; } | |
} // else empty( $qry )? | |
} // else empty( $srv )? | |
} // query_sql( $srv, $qry ) | |
$usr = "lucasribeiro"; | |
query_sql( // Testando: query_sql(); | |
"localhost root mysql.3j286", | |
"USE FERRAMENTAS; SELECT * FROM ". | |
"Login WHERE usuario=$usr" ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment