Re: What's wrong with this QUERY??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 23 July 2004 10:57, Harry G wrote:

> I have a database with members details and PK is id.
>
> $thing = "July22@xxxxxxxxx";
>
> $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?
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux