Author Topic: CGI - ODBC Example  (Read 17796 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
CGI - ODBC Example
« on: March 26, 2006, 05:45:03 PM »
Code: Script BASIC
  1. #!/usr/bin/scriba -c
  2.  
  3. INCLUDE cgi.bas
  4. INCLUDE odbc.bas
  5.  
  6. cgi::Header 200,"text/html"
  7. cgi::FinishHeader
  8.  
  9. PRINT """
  10. <HTML>
  11. <HEAD>
  12. <title>unixODBC testing</title>
  13. </HEAD>
  14. <BODY>
  15. <FONT face="Verdana, Arial, Helvetica, sans-serif">
  16. <TABLE border="1" cellpadding="3">
  17. """
  18.  
  19. ON ERROR GOTO PROBLEMS
  20.  
  21. dbh = ODBC::RealConnect("DSN","user","password")
  22.  
  23. ODBC::query(dbh,"SELECT * FROM contact")
  24.  
  25. PRINT "File Handle: <b>",dbh,"</b><br>"
  26. PRINT "Affected Rows: <b>",ODBC::AffectedRows(dbh),"</b><br>"
  27.  
  28. WHILE ODBC::FetchHash(dbh,column)
  29.  
  30. PRINT "<TR>"
  31. PRINT "<TD>",column{"ID"},"</TD>"
  32. PRINT "<TD>",column{"NAME"},"</TD>"
  33. PRINT "<TD>",column{"ADDRESS"},"</TD>"
  34. PRINT "<TD>",column{"CITY"},"</TD>"
  35. PRINT "<TD>",column{"STATE"},"</TD>"
  36. PRINT "<TD>",column{"ZIP"},"</TD>"
  37. PRINT "<TD>",column{"PHONE"},"</TD>"
  38. PRINT "<TD>",column{"EMAIL"},"</TD>"
  39. PRINT "<TD>",column{"URL"},"</TD>"
  40. PRINT "</TR>"
  41.  
  42. WEND
  43.  
  44. PRINT """
  45. </TABLE>
  46. </FONT>
  47. </BODY>
  48. </HTML>
  49. """
  50.  
  51. ODBC::Close(dbh)
  52.  
  53. END
  54.  
  55. PROBLEMS:
  56.  
  57. PRINT "ERROR = ",error(),"<br>"
  58.  
  59. RESUME
  60.  
« Last Edit: September 18, 2022, 05:04:41 PM by Support »