Re: newbie: Supplied argument is not a valid MySQL result..?
| From: | David Robley | Date: | Mon, 03 Dec 2001 23:25:53 +0000 |
| Subject: | Re: newbie: Supplied argument is not a valid MySQL result..? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76428@lists.php.net to get a copy of this message | ||
On Tue, 4 Dec 2001 08:29, Lee Philip Reilly wrote:
> Hi,
>
> I wonder if someone could point out what is wrong with the following
> piece of code (taken directly from the 'PHP - fast & easy web
> development' book) , which gives the following warning :
>
> Warning: Supplied argument is not a valid MySQL result resource in
> c:\program files\apache group\apache\htdocs\cms\pick_modcontact.php on
> line 23
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> $result = mysql_query($sql,$connection); <--line 23
Use mysql_error() here to return the error string from mysql, which will
tell you more about your problem; it will be in the code before line 23
>
> while ($row = mysql_fetch_array($result)) {
Using extract($row) here will save you typing :-)
> $id = $row['id'];
> $fname = $row['fname'];
> $lname = $row['lname'];
>
> $option_block .= "<option value=\"$id\">$lname,
> $fname</option>";
> }
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> The mySQL query that is executed returns a result set when I use the
> mySQL shell, and the connection string is valid. If someone could
> advise me as to the error, I would greatly appreciate it.
>
> - Best regards,
>
> Lee
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
He who always plows a straight furrow is in a rut.