PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/website/database.inc

https://bitbucket.org/matthewsomerville/publicwhip-v1
PHP | 69 lines | 44 code | 12 blank | 13 comment | 3 complexity | 636b331953d6d99acfaf0551484832fd MD5 | raw file
Possible License(s): AGPL-1.0, BSD-3-Clause
  1. <?php
  2. // This files used for user login, should be merged with db.inc (patches
  3. // welcome :)
  4. //
  5. // SourceForge: Breaking Down the Barriers to Open Source Development
  6. // Copyright 1999-2000 (c) The SourceForge Crew
  7. // http://sourceforge.net
  8. //
  9. // $Id: database.inc,v 1.5 2011/05/10 22:54:03 publicwhip Exp $
  10. //
  11. // /etc/local.inc includes the machine specific database connect info
  12. function db_connect() {
  13. global $pw_host,$pw_user,$pw_password;
  14. $conn = mysql_connect($pw_host,$pw_user,$pw_password);
  15. if (!$conn) {
  16. echo mysql_error();
  17. }
  18. return $conn;
  19. }
  20. function db_query($qstring,$print=0) {
  21. global $pw_database;
  22. @mysql_select_db($pw_database);
  23. return @mysql_query($qstring);
  24. }
  25. function db_numrows($qhandle) {
  26. // return only if qhandle exists, otherwise 0
  27. if ($qhandle) {
  28. return @mysql_numrows($qhandle);
  29. } else {
  30. return 0;
  31. }
  32. }
  33. function db_result($qhandle,$row,$field) {
  34. return @mysql_result($qhandle,$row,$field);
  35. }
  36. function db_numfields($lhandle) {
  37. return @mysql_numfields($lhandle);
  38. }
  39. function db_fieldname($lhandle,$fnumber) {
  40. return @mysql_fieldname($lhandle,$fnumber);
  41. }
  42. function db_affected_rows($qhandle) {
  43. return @mysql_affected_rows();
  44. }
  45. function db_fetch_array($qhandle) {
  46. return @mysql_fetch_array($qhandle);
  47. }
  48. function db_insertid($qhandle) {
  49. return @mysql_insert_id($qhandle);
  50. }
  51. function db_error() {
  52. return "\n\n<P><B>".@mysql_error()."</B><P>\n\n";
  53. }
  54. //connect to the db
  55. //I usually call from pre.php
  56. db_connect();
  57. ?>