Re: Error Msg: Wrong data type when performing "extract()"
| From: | CC Zona | Date: | Thu, 19 Apr 2001 05:09:15 +0000 |
| Subject: | Re: Error Msg: Wrong data type when performing "extract()" | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-8689@lists.php.net to get a copy of this message | ||
In article <3ADE5038.F47F4701@sains.com.my>,
shahmatd@sains.com.my ("Shahmat Dahlan") wrote:
> $result=mysql_query($sqlstmt);
> # print $result;
> $row=mysql_fetch_array($result)
>
> extract($row);
>
> If I do the above, I get the results below:
>
> Warning: Wrong datatype in call to extract() in
> E:\winnt\temp\stock_in.php on line 39
>
> I've went through the query, and it seems alright. It worked previously,
> now all of a sudden it doesn't work anymore.. Can anyone help me out.
Since apparently $row is not an array, I'd guess that mysql_fetch_array has
nothing to fetch (i.e. no row was returned by the query). Two things to
get into the habit of doing:
1) check that the query was valid. For example:
$result=mysql_query($sqlstmt) or die("Query error: " . mysql_error());
2) check that the query returned 1 or more rows. For example:
if(mysql_num_rows())
{
$row=mysql_fetch_array($result) or die("Row fetching error: " .
mysql_error()); //BTW, you were missing a semi-colon on this line
...
}
--
CC