db_functions.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 getSQLRowArray($Result){
  34. if(function_exists("mysql_fetch_row")){
  35. return mysql_fetch_row($Result);
  36. }else{
  37. return mysqli_fetch_row($Result);
  38. }
  39. }
  40. function escapeSQLStr($str, $connection){
  41. if(function_exists("mysql_real_escape_string")){
  42. return mysql_real_escape_string($str);
  43. }else{
  44. return mysqli_real_escape_string($connection, $str);
  45. }
  46. }
  47. ?>