# CGI with DBI error - cant use both at the same time

**URL:** <https://www.ruby-forum.com/t/cgi-with-dbi-error-cant-use-both-at-the-same-time/108529>\
**Category:** Ruby\
**Created:** [July 4, 2007, 12:55pm UTC](https://www.ruby-forum.com/t/cgi-with-dbi-error-cant-use-both-at-the-same-time/108529 "2007-07-04T12:55:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![galecho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@galecho](https://www.ruby-forum.com/u/galecho)\
**Post date:** [July 4, 2007, 12:55pm UTC](https://www.ruby-forum.com/t/cgi-with-dbi-error-cant-use-both-at-the-same-time/108529/1 "2007-07-04T12:55:28Z")

</div>

Hi,

I’m using Ruby’s CGI to handle some forms, and the form input is to be  
further used to query a database. But I’m getting errors when I try to  
use the DBI module to connect to the database. Even just typing  
“require ‘dbi’” is screwing up things. For instance in the following  
code, nothing would show up unless I remove “require ‘dbi’”.

#!/usr/local/bin/ruby -w  
print “Content-type: text/plain\n\n”  
require “cgi”  
require “dbi”

puts “Thanks- form submitted”

If instead of using the print command, I try to use cgi.out then I get  
“500 Internal Server Error”. Does anyone know a fix to this problem ?

Thanks,  
Gale

---

<div class="post-metadata">

**Author:** ![galecho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@galecho](https://www.ruby-forum.com/u/galecho)\
**Post date:** [July 6, 2007, 12:07am UTC](https://www.ruby-forum.com/t/cgi-with-dbi-error-cant-use-both-at-the-same-time/108529/2 "2007-07-06T00:07:21Z")

</div>

Any idea how to fix this, folks ?

Gale

---

<div class="post-metadata">

**Author:** ![galecho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@galecho](https://www.ruby-forum.com/u/galecho)\
**Post date:** [July 6, 2007, 3:40am UTC](https://www.ruby-forum.com/t/cgi-with-dbi-error-cant-use-both-at-the-same-time/108529/3 "2007-07-06T03:40:51Z")

</div>

On Jul 4, 2007, at 5:55 AM, Gale CC wrote:

> ## require “cgi”
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

move the cgi out statement below the require cgi statement
