#!/usr/bin/perl -w use DBI; $address = "some.address; $database = "databasename"; $username = "database_username_that_has_the_privellge_to_insert"; $password = "some_pass"; $table = "some_table"; if ($password eq '') { $pwstring = ''; } else { $pwstring = '-p=$password' }; #getting the vaariables from stdin print ("\nDataBase Filler Written By KRAS| "); print ":)\n\n"; while (1>0) { print ("Genre: "); $genre = ; chop ($genre); print ("Author: "); $author = ; chop ($author); print ("Name: "); $name = ; chop ($name); print ("Price: "); $price = ; chop ($price); #load the driver for mysql $drh=DBI->install_driver('mysql') || cgidie("Could not load mysql driver\n"); $dbh=$drh->connect("$database:$address","$username","$password") || cgidie("Failed to connect to mysql server\n"); $cursor=$dbh->prepare("describe $table") || cgidie("Describe failed: describe $table"); $cursor->execute; $cursor=$dbh->prepare("insert into $table values ('$genre', '$author', '$name', '$price' )") || cgidie("Prepare failed."); $cursor->execute || cgidie("Execute Failed!".$cursor->errstr); print "Added Succesfully\n\n"; } sub cgidie { ($die_str) = @_; print "CGI_Error: $die_str"; die $die_str; }