No i never mind ,.....yes you are right PHP CGI and PHP apache have different scenrio and this is the problem.... i tested my script on PHP CGI as well and their it run very Well without any problem
here is my script
Please Dont concentrate on queries and query variables because i changed them in hurry so might have some problem but try to check the code.. according to me the code does not have any error as it is running well on my CGI Server but PHP server is the main problem...
////////////////// Code is ///////////////
<?php
$con = mysql_connect('localhost','user','pass');
mysql_select_db('database',$con);
$cnt=1;
$f=0;
$flag = 0 ;
$nor_item = " ";
$ch=mysql_query("select * from mytable order by id desc");
while($row=mysql_fetch_array($ch))
{
$cat_query=$row['id'];
$category=mysql_query("select * from mytable 2",$con);
if ($category)
{
$row_cat=mysql_fetch_assoc($category);
//echo '<td><font face="Verdana" size="2">'. $row_cat['pcategory_id'].'</td>';
$cat_id=$row_cat['category_id'];
$supplier=mysql_query("select * from mytable 3",$con);}
else
{
}
if ($supplier)
{
$supp_row=mysql_fetch_assoc($supplier);
}
else {
}
if ($category && $supplier)
{
$temp_table = "INSERT INTO `mp` (`id`,`cid`, `cname`, `pname`, `quantity`, `supplier`, `supplier_email`) VALUES ('$cat_query','$cat_id','".$supp_row['pc']."','".$row['pr']."','".$row['qu']."','". $supp_row['su']."','".$supp_row['s']."')";
mysql_query($temp_table,$con);
}
else
{
$not_registered_items.=$row['products_name']. "\r\n";
}
//echo "</tr>";
$cnt++;
}
$distinct = "SELECT DISTINCT (`cname`) FROM `mp`";
$res_distinct = mysql_query($distinct,$con);
$categories = array();
while ($row_distinct = mysql_fetch_assoc($res_distinct))
{
$categories[] = $row_distinct['cname'];
}
foreach($categories as $show)
{
//echo "<br>For ".$show." We have the following <br>";
$pro_distinct = "select * from mp where category_name = '$show'";
$pro_distinct_result = mysql_query($pro_distinct,$con);
//echo "<ul>";
$random_hash = md5(date('r', time()));
$headers = "From: abc <
abc@abc.co.uk> \r\nReply-To:
sales@abc.co.uk";
//add boundary string and mime type specification
$headers.= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
$subject = "Products Price and Availibilty";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<b>Dear Sir / Madam</b>
<table width="480" border="1">
<tr>
<td><div align="center"><b>MID</b></div></td>
<td><div align="center"><b>Name</b></div></td>
<td><div align="center"><b>Required </b></div></td>
<td><div align="center"><b> </b></div></td></tr>
<?php
while ($pro_row_distinct = mysql_fetch_assoc($pro_distinct_result))
{
$to = $pro_row_distinct['email'];
?><tr>
<td> <?php echo $pro_row_distinct['id']; ?> </td>
<td> <?php echo $pro_row_distinct['pe']; ?> </td>
<td> <?php echo $pro_row_distinct['ty'];?> </td>
<td> </td>
</tr>
<?php
}?>
</table>
<br />
<?php
$msg= ob_get_clean();
$bits = explode(",", $to);
foreach($bits as $to)
{
$mail_sent=mail($to,$subject,$msg,$headers);
} }
$truncate_query = "truncate `mp`";
mysql_query($truncate_query,$con);
if ($not_registered_items != " ")
{
$to="
abcabc@hotmail.com";
$header="From: abc <
abc@abc.co.uk>";
$subject="noducts";
$mail_sent=mail($to,$subject,$not_registered_items,$headers);
}
die (" "); ?>