List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 28 1999 5:56pm
Subject:Re: spaces in variables/fields
View as plain text  
At 12:42 AM -0400 6/25/99, Reuben Yau wrote:
>I have a table with a varchar(40) field (among others) which contains
>multiple words, (such as a book title) but when I use perl's DBI to connect
>and run the following:
>$dsn = "DBI:mysql:database=database;host=sqlhost";
>$dbh=DBI->connect($dsn, "login", "passwd");
>$sth = $dbh->prepare("SELECT * from table);
>while( (@results = $sth->fetchrow) != NULL) {
>  print "ID: $results[0]\n";
>  print "Title: $results[1]\n";
>  print "<p>\n";
>The $results[1] variable only contains the first word from the mysql field.
>How can I push the whole field value into the variable?

Use $sth->fetchrow_array.

Paul DuBois, paul@stripped
Northern League Chronicles:
spaces in variables/fieldsReuben Yau25 Jun
  • Re: spaces in variables/fieldsPaul DuBois28 Jun