Ciao,
ho scaricato un file php, che dovrebbe estrapolare dati da un database e traferirli in un file .txt.
Esce pero' un errore: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

Questo il file php

<?php

$dbhost = dbhost;
$dbuser = 'dbuser';
$dbpass = 'dbpass';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'nomedb';
mysql_select_db($dbname);

$query = "
select p.products_id,
pd.products_name,
pd.products_description,
manufacturers.manufacturers_name as mfgName,
manufacturers.manufacturers_id,
p.products_price,
p.products_image,
p.products_weight,
p.products_quantity
from products p
left join products_description pd on p.products_id = pd.products_id
left join manufacturers on manufacturers.manufacturers_id = p.manufacturers_id
where p.products_status = '1' and p.products_quantity > '0' order by p.products_id";

$datafile="miodominio-googlebase.txt";

$products_query = mysql_query($query);

$file = fopen($datafile, "w");

$file_header = "id\tcondizione\tlink\ttitolo\tmarca\tdescrizione\ tprezzo\tpeso spedizione\tlink_immagine\tquantit&agrave;\tmpn\n" ;
fwrite($file, $file_header);

while ($products = mysql_fetch_array($products_query)) {

$descr_clean = preg_replace("/^[^a-z0-9]?(.*?)[^a-z0-9]?$/i", "$1", strip_tags($products['products_description']));

$_strip_search = array(
"![\t ]+$|^[\t ]+!m",
'%[\r\n]+%m');
$_strip_replace = array(
'',
' ');
$_cleaner_array = array(">" => "> ", "&reg;" => "", "®" => "", "&trade;" => "", "™" => "", "\t" => "", " " => "");

$descr_clean = preg_replace($_strip_search, $_strip_replace, strip_tags(strtr($products['products_description'], $_cleaner_array)));

if(!file_exists("images/".$products['products_image'])) {
$image = "http://miosito/images/no_image.png";
} else {
$image = "http://miosito/images/".$products['products_image'];
}

$price = number_format($products['products_price'], 2, '.', '');

$prod_line = $products['products_id']."\tnuovo\thttp://www.nauticavo.com/product_info.php?products_id=".$products['products_id']."\t".$products['products_name']."\t".$products['mfgName']."\t".substr($descr_clean, "0", "400")."\t".$price."\t".$products['products_weight']."\t".$image."\t".$products['products_quantity']."\t".$products['products_id']."\n";

$line_to_write = htmlentities($prod_line);

fwrite($file, $line_to_write);
}

fclose($file);
?>