Advertisement
Guest User

Untitled

a guest
Aug 11th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2. $dsn="mysql:dbname=blog;host=localhost";
  3. $dbuser="root";
  4. $dbpass="";
  5.  
  6. try{
  7. $pdo =new PDO($dsn,$dbuser,$dbpass);
  8.  
  9. /*select*/
  10. $Sql = "SELECT *FROM usuarios";
  11. $Sql = $pdo->query($sql); //classe metodo pdo
  12. if($Sql->rowCount() >0){ //rowcount numero de linhas
  13.  
  14. echo "possui usuarios";
  15. }else{
  16. echo "nao a usuarios cadastrados";
  17.  
  18.  
  19. }
  20.  
  21. }catch(PDOException $e){
  22.  
  23. echo "falhou".$e->getMessage();
  24.  
  25.  
  26. }
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement