Re: Join in MySQL-select doesn't work
| From: | David Robley | Date: | Wed, 18 Sep 2002 22:38:32 +0000 |
| Subject: | Re: Join in MySQL-select doesn't work | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116804@lists.php.net to get a copy of this message | ||
In article <3D87824F.6010900@netscape.net>, henningolsen36@netscape.net
says...
> Hello
> I'm using PHP4 and MySQL on Apache webserver.
> I have a table valled "liste" with names of some people, and a table
> called "postnummer" with zip-codes and citynames.
> My select should join the adress and zip from one table with the
> cityname from the other table.
> But my join-line does not work. =:(
>
> My code results in this line:
>
> Warning: Supplied argument is not a valid MySQL result resource in
> /var/www/html/find/resultat.php on line 27
>
> The code is:
> mysql_select_db("adresser");
> $query = ("SELECT fornavn, efternavn, gade, postnummer.postnummer,
> postnummer.postbynavn FROM liste
> left outer join postnummer on liste.postnummer = postnummer.postnummer
> WHERE MATCH (fornavn, efternavn) AGAINST ('$search');");
> $result = mysql_query($query);
Add here
echo mysql_error();
which will return you an error string from mysql which will probably be an
error in your query syntax. It might also be useful to echo $query to
ensure that it contains what you expect it does (possible register_globals
problem?)
> while(list($cpr, $fornavn, $efternavn, $gade, $postnummer, $postbynavn) =
> mysql_fetch_row($result))
>
> What is going on?
> The select is ok if I do not join, but then I'm not able to get the
> field "postbynavn" from the other table.
>
> PLEASE HELP!
--
David Robley
Temporary Kiwi!
Quod subigo farinam