Re: Supplied argument is not a valid MySQL result resource
| From: | Stuart Dallas | Date: | Thu, 20 Jun 2002 10:09:04 +0000 |
| Subject: | Re: Supplied argument is not a valid MySQL result resource | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103099@lists.php.net to get a copy of this message | ||
On Thursday, June 20, 2002, 9:19:27 AM, webmaster@tececo.com wrote:
> <?
> $link = mysql_pconnect("localhost", "root", "") or
> die("Could not connect");
> mysql_select_db("tececo") or die("Could not select database");
> $fn = explode("/", $_SERVER['PHP_SELF']);
> $num_of_s = count($fn) - 1;
> $fn = "$fn[$num_of_s]";
> $query = "SELECT * FROM meta_data WHERE page_name = $fn";
> $result = mysql_query($query);
> $num_results = mysql_num_rows($result);
> $row = mysql_fetch_array($result);
> $id = $row['id'];
> $title = $row['title'];
> $description = $row['description'];
> $keywords = $row['keywords'];
?>>
> I get this error:
> Warning: Supplied argument is not a valid MySQL result resource in C:\TecEco(Converting To
> PHP)\includes\meta.array_create.php on line 9
> Warning: Supplied argument is not a valid MySQL result resource in C:\TecEco(Converting To
> PHP)\includes\meta.array_create.php on line 10
> Why?
This indicates an error in your SQL statement. I would suggest printing $query
to make sure it contains what you think it should. is $fn numeric? If not then
it should be enclosed in quotes in the SQL statement.
--
Stuart