perl - Can I display the output of MySQL using CGI? -


Hello, I've written a program in Perl using the DBI module. Can I display the output of MySQL using CIG? If so please help me.

Program:

  #! Use / usr / bin / perl -w DBI; Print "content-type: text / html \ n \ n"; $ Db_handle = DBI- & gt; Connect ("dbi: mysql: database = CYP1B1; host = localhost: 192.168.3.93;") or die "could not connect to the database: $ DBI :: errstr \ n"; $ Sql ​​= "Select from BPCG"; $ Statement = $ db_handle-> Ready ($ sql) or die "query '$ sql' could not be created: $ DBI :: errstr \ n"; $ Statement-> Execute () or die "query '$ sql' could not be executed: $ DBI :: errstr \ n"; Print "Location \ tNucleotidechange \ tAmenoacidchange \ n"; While (($ location, $ Nucleotidechange, $ Aminoacidchange) = $ statement- & gt; fetchrow_array ()) {Print "$ location $ Nucleotidechange $ Aminoacidchange \ n"; } $ Db_handle- & gt; Disconnect ();  

You have a CGI script that is close enough that you do not have any HTML output However, it is different from the output space, change your content type to 'text / plain'.

You need a webserver to run your CGI script, see something about Lighttpd or apache and how to setup CGI scripts (for example,). Sorry, nothing is very useful on that, the topic of establishing a webserver is very complex, but hopefully some search terms will set you in the right direction.

Alternatively, keep in mind that this is not a modern way to write something for the web if you are probably looking for (really to quickly solve a problem), then I suggest Let me know that you learn a framework such as the catalyst (on CPAN). There is a lot more work for you, but whatever you are trying to do it will be easy to do for a long time.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -