Advertisement
Guest User

Untitled

a guest
May 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3. $db_server="localhost";
  4. $db_user="root";
  5. $db_password="Root123.";
  6. $db_name="users";
  7. $connection=mysqli_connect($db_server,$db_user, $db_password);
  8.  
  9. $mysql_query="select*from users";
  10. if(!$connection){
  11. die("nuk lidhemi me db ".mysqli_error($connection));
  12. }
  13. else{
  14.  
  15. echo"lidhjs me db ishte e sukseshme";
  16. }
  17. //2. zgjedhim db
  18. $db_select=mysqli_select_db( $connection,$db_name);
  19. if(!$db_select){
  20.  
  21. die("nuk u zgjodh db":.mysql_error());
  22. }
  23. else{
  24.  
  25. echo "u realizua lidhja me db".$db_name;
  26. }
  27. ?>
  28.  
  29. <html>
  30. <head>
  31. <title>mysql ne php</title>
  32. </head>
  33. <body>
  34. <?php
  35. $users_set=mysqli_query($connection, $mysql_query);
  36. if(!$users_set){
  37. die("query nuk u exekutua:".mysql_error($connection));
  38. }
  39. while($users=mysqli_fetch_array($users_set)){
  40. echo $users["username"]. ",".$users["email"];
  41. echo "<br/>";
  42. }
  43. ?>
  44.  
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement