Re: Not a valid MySQL result resource
| From: | DL Neil | Date: | Fri, 09 Nov 2001 01:33:46 +0000 |
| Subject: | Re: Not a valid MySQL result resource | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14167@lists.php.net to get a copy of this message | ||
> <?php
> //.../... first part of the code is to connect to the right DB on a MySQL
> server. It works fine
> //This code to show the query. It runs well under MySQL and gives 1 result :
> $query="SELECT Login, Password FROM
user WHERE
> user.login=''$login'' and
> user.password=''$password''";
> //This var should contain a query result ressource:
> $result_query=mysql_query($query);
> //Here's my error message after executing:
> // Supplied argument is not a valid MySQL result resource in this line:
> $result_table=mysql_fetch_array($result_query);
> // I thought that this var ($result_table) should contain the row of 2 cells
> //And I expected to read $result_table['login'] or $result_table[0] as the
> first cell of the row...
> // I any of you can help me, poor php newby... :o) Great thanks !!
> ?>
=Please check the archives for advice about checking the result of every mysql_...() call. It's
much better to
know/be told by PHP/MySQL than to say "I thought that...I expected to ..."
=the $query assignment statement contains multiple double-quotes. These cannot be
'nested'. Use a mixture of
single and double-quotes or 'escape' the inner set(s).
=also (and this may be a function of our email packages not a PHP thing) are those single quotes
around user?
=dn