Futz Posted July 24, 2004 Posted July 24, 2004 I've managed to connect to the database, but can't issue a query (and subsequently see its result). Here is the script: ----- #! /usr/bin/perl # carp print "Content-type: text/html\n\n"; # declare mod usage use DBI; # connect to mysql db $dbh = DBI->connect("DBI:mysql:$database:localhost", $user, $passwd); print "connected.<br>"; # build query $query = "select * from $table where 1"; print "query built.<br>"; # prep due to multirow result $cursor = $dbh->prepare($query); print "query prepared.<br>"; # commented out because above doesn't work #$cursor->execute(); #print "query executed.<br>"; # clean up $cursor->finish(); $dbh->disconnect(); ---- and the output I get is: "connected. query built." Apparently there is a problem with the prepare() statement, but I can't see anything wrong with it. Any help is appreciated. Quote
LisaJill Posted July 24, 2004 Posted July 24, 2004 This is really a script issue so I'm going to move it to the script section. We have some perl coders around here that are really good so that should help them to find ya. =) Quote
Futz Posted July 25, 2004 Author Posted July 25, 2004 I found out what the problem was. I created a database and a user, but I didn't add that use to the database. Didn't realize I had to do that, I figured adding the user would take care of that. Had to write a script that would run my script from the command line and grab the error to discover that. Quote
TCH-Don Posted July 25, 2004 Posted July 25, 2004 Yes that is the step we all miss the most When you create a user, you may have many databases so you need to select the proper database to add the user to. Thank you for the followup. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.