Announcement

Collapse
No announcement yet.

CGI conversion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CGI conversion

    Is it possible to take my cgi programs, and easily convert them to php? I want to get away from using my flat file system, and use more of the VB database. Idealy, I would like to get everything to revolve around VB on my site, including all of my current CGI apps...
    Whassup!!!
    :cool:

  • #2
    If your CGIs are too big, then I suggest using the DBI module with DBD::MySQL so that you can interact with vBulletin's MySQL database , a typical DBI script might look like this:
    Code:
    #!/usr/bin/perl -w
    ###################
    # SQL Rocks!!!
    ###################
    
    use strict;
    use DBI;
    use CGI; # If you need it
    use CGI::Carp qw(fatalsToBrowser);
    
    my $dbname = 'DataBase';
    my $dbuser = 'you';
    my $dbpass = 'password';
    my $what_are_you_looking_for = 'Anything';
    
    # Connection
    my $dbh = DBI->connect("dbi:mysql:$dbname","$dbuser","$dbpass") 
    || die("Unable to establish connection to MySQL for this reason: $DBI::errstr");
    
    # Prepare query
    my $sth = $dbh->prepare("select * from TABLE where id = ?");
    $sth->execute("$what_are_you_looking_for");
    
    while(my(@array_of_results) = $sth->fetchrow_array) {
    # Do stuff ... anything .... @array_of_results contains
    # each row's data
    }
    
    # Disconnect
    $dbh->disconnect;
    
    # That's it ...
    Last edited by JB007; Tue 30th Jan '01, 6:27pm.

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X