<?xml version="1.0" encoding="windows-1252"?>
<node id="165498" title="Problems with MySQL - &quot;No Database Selected&quot;" created="2002-05-09 16:37:29" updated="2005-08-13 11:28:25">
<type id="115">
perlquestion</type>
<author id="121706">
ninja-joe</author>
<data>
<field name="doctext">
I'm trying to do a basic select but I'm running into an error message:&lt;br&gt;
No Database Selected&lt;br&gt;

Here's the code I used (password, domain and user have been changed for privacy purposes)

&lt;code&gt;
#!/usr/bin/perl

use DBI;

use CGI qw/:standard/;
import_names('f');
print header();

my $database = "databasename=default";
my $host = "host=mysql.domain.com";
my $driver = "DBI:mysql";
my $user = "user";
my $pass = "pass";

my $dbh = DBI-&gt;connect("DBI:mysql:$database;$host", $user, $pass)
	or print "Can't connect to mysql database: $DBI::errstr&lt;br&gt;";

$sth = $dbh-&gt;prepare("SELECT section, content FROM webdata WHERE section=home")
	or print "Can't prepare statement: $DBI::errstr&lt;br&gt;";

$sth-&gt;execute()
	or print "Can't execute statement: $DBI::errstr&lt;br&gt;";

$dbh-&gt;disconnect();

&lt;/code&gt;

The code doesn't flag any syntax errors, so I'm a little confused. Is it me or something I should email the sysadmin about?</field>
</data>
</node>
