adding fields to mySOL

stephenblade
stephenblade used Ask the Experts™
on
Am connecting using the following...
<<CODE SNIPPET>>
$dsn = "DBI:$dbDriver:database=$dbName";
$db_handle = DBI->connect($dsn, $usrName, $dbPassword);
<<END CODE SNIPPET>>

How can I add fields to the db?

::StephenBlade

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
$dbh = DBI->connect("DBI:mysql:dbname", "usr", $pass) or
    die "unable to connect to the database: $DBI::errstr\n";

$wquery = qq( insert into addresses (name,email,tel) values (?,?,?));
$sth = $dbh->prepare($wquery) or die $dbh->errstr;
      $sth->execute($name,$email,$tel) or die $sth->errstr;

see full working demo @ www.perlnow.com script mysql

Author

Commented:
How do I create the table "addresses"?

Commented:
create table addresses ( id integer not null auto increment, name VARCHAR(64), email VARCHAR(64), tel CHAR(16) );

Author

Commented:
So what am I doing wrong? I just want to create the table right now..


$dsn = "DBI:$dbDriver:database=$dbName";

$db_handle = DBI->connect($dsn, $usrName, $dbPassword);

if( $db_handle )
{
print "connected";
create table registrations ( id integer not null auto increment, name VARCHAR(64), email VARCHAR(64), add1 CHAR(64), add2 CHAR(64), add3 CHAR(64), bids CHAR(600));
print "Tables Created";
 } else {
print "Error";
}

Commented:
see code above. 'create table' should be part of a query string that you define before preparing and executing a query.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial