Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
error in execution.

Posted by revtopo (revtopo), 27 September 2007
I have written a code to get a list of projects with id =72 using perl scripts. I have connected that with mysql database using DBI.

my code goes goes this way:

use DBI;
use strict;
my $connect;
my $database = 'Cloned_RNA_2_dev';
my $user ='root';
my $pass = '';
my $host = 'localhost';
my $dsn = qq(DBI:mysql:database = $database; host = $host);
$connect = DBI-> connect($dsn, $user, $pass,{printError =>1}) or die $DBI::errstr;
my $query = $connect->prepare(qq(Select c.Rna_sequence_sequence, c.clone_name, p.idproject, p.description, h.hit_start, h.hit_end, h.hit_string from Cloned_rna c, Project p, Hsp h where c.Rna_sequence_sequence = h.Rna_sequence_sequence and c.Project_idproject = p.idproject and c.Project_idproject = 72));
$query-> execute;
while (my @hit = $query->fetchrow_array()){
print "$hit[0]: $hit[1]: $hit[2]: $hit[3]: $hit[4]: $hit[5]:$hit[6]<br>";
}

the error i get are::
DBD::mysql::st execute failed: No database selected at extract_hit.pl line 12.
DBD::mysql::st fetchrow_array failed: fetch() without execute() at extract_hit.pl line 13.

and further am loging in to the database as a' root 'which doesnt have a  password. Is that the way i have done is right or should i have to omit the password?
could any one help me  out of this.

thanks in advance.



Posted by admin (Graham Ellis), 27 September 2007
Try something like

$dsn='DBI:mysql:test:localhost';

Your use of "database =" within the string is something that I have not used and may be causing problems.

Also check your return statuses to see where the program goes wrong;  as it stands at the moment you assuming everyting  works correctly and blundering onwards ...

Posted by KevinAD (KevinAD), 27 September 2007
As far as I know, the use of "=" in the connection string is OK.

Not sure what the problem is.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho