Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2. function countusers($connection, $column, $table)
  3. {
  4. $stmt = mysqli_prepare($connection, "
  5. SELECT
  6. COUNT($column)
  7. FROM
  8. $table");
  9. if($stmt)
  10. {
  11. mysqli_stmt_bind_result($stmt, $num);
  12. mysqli_execute($stmt);
  13. mysqli_stmt_fetch($stmt);
  14. mysqli_stmt_close($stmt);
  15. }
  16. return $num;
  17. }
  18.  
  19. <?php
  20. require_once "conn.php";
  21. include "func.php";
  22. echo countusers($conn, "id", "mods");
  23.  
  24. <?php
  25. $conn = mysqli_connect("localhost", "root", "", "test", 3306);
  26. if(!$conn)
  27. {
  28. echo "An Error Occurred";
  29. }
  30.  
  31. //... SNIP...
  32. if($stmt)
  33. {
  34. mysqli_stmt_execute($stmt); // Changed this to mysqli_stmt_execute
  35. mysqli_stmt_bind_result($stmt, $num);
  36. mysqli_stmt_fetch($stmt);
  37. mysqli_stmt_close($stmt);
  38. }
  39. return $num;
  40. // ... SNIP ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement