Jun 28, 2001, 9:28 AM
Post #1 of 4
I am just learning how to spell SQL, and am attempting to get the basics down. In this quest, I have written a very simple script by using some examples I found. Not quite cut&paste since I am trying to understand the reasoning behind each line...
problem with mySQL script.
My script is below, but it does not seem to be working correctly. I get no errors, and no output either! (see the " print "Script complete"; " command at the end)
Here is the necessary info, as far as I can tell. If something is missing let me know...
I used a few different types of fields, just to get the practice and see how each is handled...
Database name: 'maebius'
Table name: 'test'
contents of table:
testID - a tinyint, primary key.
testName - a varChar(20)
testNumber - a tinyint (5)
testSet - a set with the contents ('red','yellow','green','blue')
I have tried commenting out indivifual sections of the script, and it seems to hang up around the "$sth->execute(test)..." area, or the line above...
If these are commented out, the script runs and I get the output "Script Complete". When there is no output, everything seems to run fine since the browser does not continually "load", or anything else.
print "Content-type: text/html\n\n";
my $DSN = "DBI:mysql:maebius";
my $user = "username";
my $pw = "password";
$dbh = DBI->connect($DSN,$user,$pw) or print "Cannot connect: $DBI::errstr\n";
my $query = " select testID,testName,testNumber,testSet from test where testName = * ";
my $sth = $dbh->prepare($query) or print "$DBI::errstr\n";
$sth->execute(test) or print "$DBI::errstr\n";
#while ( my($testID,$testName,$testNumber,$testSet) = $sth->fetchrow_array())
#print " $testID _ $testName _ $testNumber _ $testSet \n";
print "Script complete.";
Living life -umop apisdn-