RE: FIXED Spaces in Data Fields

"Peter P. Benac" <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Fixed it. Turns out it was a loose nut between the keyboard and the chair.
Sorry for the not necessary posts

Regards,
Pete
----
Peter P. Benac, CCNA
Celtic Spirit Networking
Providing Network and Systems Project Management and Installation and Web
Hosting.
Phone: 919-618-2557
Web: http://www.emacolet.com
Need quick reliable Systems or Network Management advice visit
http://www.nmsusers.org

To have principles...
             First have courage.. With principles comes integrity!!!




-----Original Message-----
From: Peter P. Benac [mailto:[email protected]] 
Sent: Tuesday, November 09, 2004 5:58 AM
To: [email protected]; [email protected]
Subject: RE: Spaces in Data Fields


Use DBI
Use Mysql;

	$igotzip=$dbh->do("select * from ZipCode where city='$members[8]'
and state = '$members[9]'");
	
      $igotzip will be zero if the city has a space in it like Myrtle Beach.
No space it works just fine.

	    $sth=$dbh->prepare(q{select * from ZipCode where city=? and
state=?} );
	    $sth->execute ($members[8], $members[9]);

	    @Row = $sth->fetchrow();

The array will be empty if the city conatain as space.


As for my operating environment please read the other messages

----
Peter P. Benac, CCNA
Celtic Spirit Networking
Providing Network and Systems Project Management and Installation and Web
Hosting.
Phone: 919-618-2557
Web: http://www.emacolet.com
Need quick reliable Systems or Network Management advice visit
http://www.nmsusers.org

To have principles...
             First have courage.. With principles comes integrity!!!




-----Original Message-----
From: Dave Howorth [mailto:[email protected]] 
Sent: Tuesday, November 09, 2004 5:42 AM
To: [email protected]
Subject: Re: Spaces in Data Fields


 >     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]


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]


-- 
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.