| Bob Sherer 2004-07-23, 3:55 pm |
| Harmeet,
The field email is obviously a field that can accept strings. In SQL, =
you must wrap strings in single-quotes. So, rewrite your query as:
$query =3D "SELECT id, email, familyname FROM members WHERE =
email=3D'$thing'";
The reason it worked for id=3D$thing is that the id field is probably an =
integer field and integers do not require quotes.
Remember, wrap your strings in quotes and don't wrap your numbers =
(unless the number is really a string in disquise.)
Good luck,
Bob
-----Original Message-----
From: Harry G [mailto:harry (removethis)@gabha.net]
Sent: Thursday, July 22, 2004 10:59 PM
To: php-db@lists.php.net
Subject: Re: What's wrong with this QUERY?? - Thanks all.
Thank you everybody.
"Harry G" <harry@gabha.net> wrote in message
news:20040723025938.59488.qmail@pb1.pair.com...
> Hi,
>
> I have a database with members details and PK is id.
>
> $thing =3D "July22@gabha.net";
>
> $query =3D "SELECT id, email, familyname FROM members WHERE =
email=3D$thing";
> $result =3D mysql_query($query);
>
> If i do a query where id=3D$thing.
> and $thing=3D"20";
> this works fine and I get the desired result. But what is wrong with =
the
> other one, when I do search for the email address??
>
> The email address does exist exactly as quoted above in the "email" =
field
in
> my "members" table but still doesn't produce any results.
>
> Any help is much appreciated.
>
> Harmeet
|