db_functions.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. function execSQL($SQL, $connection){
  3. if($connection){
  4. if(function_exists("mysql_query")){
  5. return mysql_query($SQL, $connection);
  6. }else{
  7. return mysqli_query($connection, $SQL);
  8. }
  9. }
  10. return false;
  11. }
  12. function countSQLResult($Result){
  13. if(function_exists("mysql_num_rows")){
  14. return mysql_num_rows($Result);
  15. }else{
  16. return mysqli_num_rows($Result);
  17. }
  18. }
  19. function getSQLError($connection){
  20. if(function_exists("mysql_error")){
  21. return "Error code " . mysql_errno($connection) . ": " . mysql_error($connection);
  22. }else{
  23. return "Error code " . mysqli_errno($connection) . ": " . mysqli_error($connection);
  24. }
  25. }
  26. function getSQLRow($Result){
  27. if(function_exists("mysql_fetch_assoc")){
  28. return mysql_fetch_assoc($Result);
  29. }else{
  30. return mysqli_fetch_assoc($Result);
  31. }
  32. }
  33. function escapeSQLStr($str, $connection){
  34. if(function_exists("mysql_real_escape_string")){
  35. return mysql_real_escape_string($str);
  36. }else{
  37. return mysqli_real_escape_string($connection, $str);
  38. }
  39. }
  40. ?>