Re: Re: WHERE/AND problem in query to MySQL
| From: | David Robley | Date: | Wed, 13 Sep 2000 01:41:32 +0000 |
| Subject: | Re: Re: WHERE/AND problem in query to MySQL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16470@lists.php.net to get a copy of this message | ||
On Tue, 12 Sep 2000, viva technologies wrote:
<SNIP code>
> ...so far so good. But if I add more records in my table I need to be more
> spesific. I wanted to search for the entire form input with the following
> expression:
>
> $result = mysql_query("SELECT * FROM adresse WHERE (kommune=$kom AND
> gate=$gt AND gatenr=$gnr AND leil=$le)",$db);
>
> (Then afterwards I wanted to use the recovered ID for search in another
> table)
>
> But the output was:
>
> from forms:
>
> You have searched for Kannikgata 21 , appartment no. A9
> which is sited in Stavanger.
>
>
> Warning: 0 is not a MySQL result index in
> /home/httpd/html/script/side2g.php3 on line 42
> from db:
http://www.php.net/FAQ.php#7.12
> gatenr:
> id:
>
> I dont understand why the latter query failed?
> --
You appear to be trying to use CHAR values in your query without enclosing
them in single quotes. See the mysql documentation.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA