Re: Spaces in Data Fields

Dave Howorth <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Organization MRC Centre for Protein Engineering
Message-ID <[email protected]>
 >     Using your example below a select statement in Perl will fail if
 > I do the following
 >
 > $sentby = "Peter Benac";
 > $count = $sth->do("select * from payment_trans where sent_by=$sentby");
 >
>      The do statement returns a count of 0.  If I do a search for records on
> that field using data that does not contain a space it works.

This fails because you have not quoted the value in the select 
statement. You need to do something like:

   $count = $sth->do("select * from payment_trans where sent_by='$sentby'");


 > $sth=$dbh->prepare(q{select * from payment_trans where sent_by=?});
 > $sth->execute($sentby); $row = fetchrow();
 >
>      For that matter the prepare/execute returns a "no record found" error
> long before I hit the fetchrow.

Are you sure you have posted the exact code that you have run?
On my machine, it doesn't run at all, it fails at compile time because 
there is no fetchrow(). If I take out that error and put in 
fetchall_arrayref then it runs fine.

Your error message confuses me. It isn't an error for the select to 
return no rows, I simply get 0 rows returned and if I use a string with 
spaces that does exist in the database I get the correct number of rows. 
So I don't see why you would see an error message like that. 
Furthermore, I can't find the string 'no record found' in either DBI or 
DBD::MySQL. Where do you believe that error is coming from?

If you need more help, please post the actual running code that fails 
and the actual output from your program, and please provide the version 
numbers and environment details.

Cheers, Dave


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.