Re: What's wrong with this QUERY??
| From: | Jason Wong | Date: | Fri, 23 Jul 2004 03:27:32 +0000 |
| Subject: | Re: What's wrong with this QUERY?? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35440@lists.php.net to get a copy of this message | ||
On Friday 23 July 2004 10:57, Harry G wrote:
> I have a database with members details and PK is id.
>
> $thing = "July22@gabha.net";
>
> $query = "SELECT id, email, familyname FROM members WHERE email=$thing";
$query = "SELECT id, email, familyname FROM members WHERE email='$thing'";
Please refer to some SQL primer to learn the basics of SQL.
> $result = mysql_query($query);
Look at the examples in the manual to see how you can incorporate error
checking into your code. In particular look at mysql_error().
> If i do a query where id=$thing.
> and $thing="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??
Because your 'id' column is numeric and 'email' column is text. Text columns
needs their values enclosed by quotes.
> The email address does exist exactly as quoted above in the "email" field
> in my "members" table but still doesn't produce any results.
mysql_error() would let you know that there was an error in your query.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
I don't wish to appear overly inquisitive, but are you still alive?
*/