Oops! And switch "=" to "like" and add quotes:

$sth=$dbh->prepare("SELECT Contacts FROM Info WHERE Name like '%$sname%' ");

 $sth->execute();


----- Original Message -----
From: "Douglas Forrest" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 4:16 PM
Subject: Re: help please, patter matching problem


> No closing quotes in prepare.
>
> Also, I've never seen code that's looks quite like that; this may be
> cleaner:
>
> $sth=$dbh->prepare("SELECT Contacts FROM Info WHERE Name=%$sname%");
>
>  $sth->execute();
>
>
> ----- Original Message -----
> From: "Dan" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, January 12, 2002 9:49 AM
> Subject: help please, patter matching problem
>
>
> > mysql and Perl
> >
> > Can someone tell me what's wrong with this code:
> >
> > $sth=$dbh->prepare("SELECT Contacts FROM Info WHERE Name=?);
> >
> > $sth->execute("%$sname%");
> >
> > $dname = $sth->fetchrow_array;
> >
> > $names is supposed to be a substring. So if I want to search for a
middle
> > name or just a first name or even a last name.
> >
> > Any help is greately appreciated.
> >
> > Daniel.
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to