From: Aldrian Gintingsuka Date: March 25 1999 9:39am Subject: Re: Extracting a given row using Perl API List-Archive: http://lists.mysql.com/mysql/935 Message-Id: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII You forgot to include the quotes!!! They are necessary to parse your variable as a string or otherwise it will interpreted as a table name. my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE phone_book.last='$FOO'"); ======================================================================== Aldrian Gintingsuka -- Systems Consultant -- Mitra Integrasi Informatika Phone: +62-21-251-1360 ext. 1414 -- Fax: +62-21-251-2748 Email: aldrian@stripped, aldrian@stripped ------------------------------------------------------------------------ Si tu es contre Dieu, tu es contre l'homme (Enigma: Sadeness part I) On Wed, 24 Mar 1999, William R. Mattil wrote: wrmattil> Can anyone tell me where the problem here is ??? wrmattil> wrmattil> wrmattil> Given a rather simple table phone wrmattil> +----------+----------+------------+ wrmattil> |first |last |phone | wrmattil> +----------+----------+------------+ wrmattil> |Joe |Blow |800-555-1212| wrmattil> +----------+----------+------------+ wrmattil> wrmattil> In this rather simplistic example: wrmattil> wrmattil> my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE wrmattil> phone_book.last='Blow'"); wrmattil> wrmattil> works while the following does not; wrmattil> wrmattil> my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE wrmattil> phone_book.last=$FOO"); wrmattil> wrmattil> Where $FOO = 'Blow'; And the error message returned is as follows: wrmattil> wrmattil> DBD::mysql::st execute failed: Unknown column 'Blow' in 'where clause' wrmattil> at ./find-record line 23. wrmattil> wrmattil> I'm sure that I am making a grievous error here but just can't see it. wrmattil> Can anyone shed some light on this ??? wrmattil> wrmattil> wrmattil> Thanks in Advance wrmattil> wrmattil> Bill