Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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