Re: Conditional search from two tables?
| From: | Jayme Jeffman Filho | Date: | Wed, 20 Sep 2000 15:50:48 +0000 |
| Subject: | Re: Conditional search from two tables? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2989@lists.php.net to get a copy of this message | ||
The problem is located in the line bellow:
> $result9 = mysql_query("SELECT * FROM kommentar WHERE
(id=$myrow8["id"]) ", $db);
The select statement was closed when you write the second " so you have to
change it to:
$result9 = mysql_query("SELECT * FROM kommentar WHERE (id=" . $myrow8["id"]
. ") ", $db); You may also ad slashes to it but some times it becomes a
unreadable code, I'd rather this way.
I hope this helps.
Jayme.
http://www.conex.com.br/jjeffman
-----Mensagem Original-----
De: Knut Lekvam <lekvam@sensewave.com>
Para: <php-db@lists.php.net>
Enviada em: quarta-feira, 20 de setembro de 2000 07:03
Assunto: [PHP-DB] Conditional search from two tables?
> I have a MySQL table called "adresse" with a tinyint row called "id". I
want to use it in a second search in another table, "kommentar", wich also
has a tinyint row called "id". I used this script:
>
> $result8 = mysql_query("SELECT * FROM adresse WHERE (gate='$gt')",$db);
> while ($myrow8 = mysql_fetch_array($result8)) {
> echo $myrow8["id"];
> $result9 = mysql_query("SELECT * FROM kommentar WHERE
(id=$myrow8["id"]) ", $db);
> $myrow9 = mysql_fetch_array($result9);
> echo $myrow9["id"];
> }
>
> This gave the following error:
>
> "Parse error: parse error, expecting
STRING' or
> NUM_STRING' or `'$'' in
> /home/httpd/html/script/side2.php3 on line 68"
>
> It works ok if I put in (id=2) instead of (id=$myrow8["id"])
>
> (it prints out my first id value in both cases, but it halted on the
second when the error came).
>
> Why cant I use (id=$myrow8["id"]) here? and how can I pick out values from
the second db based on the first search ?
>
> I think I have now understood the point in differentiating between char
and int which David Robley and zeles pointed out to me after my last
question. (Now the char variable is working nice in my first search
statement)
>
> --
> Knut Lekvam
>
> __________________________________________________________________
>
> Denne eposten er sendt ved hjelp av http://www.Organizer.net
> - Norges ledende webbaserte kommunikasjonsløsning.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>