?
Solved

sometimes this file runs, other times it crashes fastcgi

Posted on 2010-11-20
4
Medium Priority
?
205 Views
Last Modified: 2012-05-10

I have tried running using commandline, codeeditor, and browser
sometimes where  I run this one php file I get error

fastcgi/cgi stopped working  


Fault Module Version:      5.2.6.6
  Fault Module Timestamp:      481b9057
  Exception Code:      c0000005
  Exception Offset:      00005948
  OS Version:      6.0.6002.2.2.0.1296.17
  Locale ID:      1033
  Additional Information 1:      fd00
  Additional Information 2:      ea6f5fe8924aaa756324d57f87834160
  Additional Information 3:      fd00
  Additional Information 4:      ea6f5fe8924aaa756324d57f87834160
<?php
require_once('../common.php');


$dir="D:/Files";
$files = scandir($dir, 1);   
foreach ($files as $f){    
  
  
  
$string=$f;
$string = str_replace(".txt", "", $string);
$parts = explode("_", $string);
 
$data=file("$dir/$f");  
unset($data[0]); 


foreach($data as $v){ 
        $v=explode("\t",$v); 
 $nb = count($v);
 if ($nb>48){
 $nb=48;
 }

if($parts[1]=='FBA'){
$sql="
insert into af(country,fulfilled,amazonorderid,merchantorderid,shipmentid,shipmentitemid,amazonorderitemid,merchantorderitemid,purchasedate,paymentsdate,shipmentdate,reportingdate,buyeremail,buyername,buyerphonenumber,sku,productname,quantityshipped,currency,itemprice,itemtax,shippingprice,shippingtax,giftwrapprice,giftwraptax,shipservicelevel,recipientname,shipaddress1,shipaddress2,shipaddress3,shipcity,shipstate,shippostalcode,shipcountry,shipphonenumber,billaddress1,billaddress2,billaddress3,billcity,billstate,billpostalcode,billcountry,itempromotiondiscount,shippromotiondiscount,carrier,trackingnumber,estimatedarrivaldate,fulfillmentcenterid,fulfillmentchannel,saleschannel ) select
";
}else if ($parts[1]=='FBM'){
$sql="
insert into am(country,fulfilled,orderid,orderitemid,purchasedate,paymentsdate,buyeremail,buyername,buyerphonenumber,sku,productname,quantitypurchased,currency,itemprice,itemtax,shippingprice,shippingtax,shipservicelevel,recipientname,shipaddress1,shipaddress2,shipaddress3,shipcity,shipstate,shippostalcode,shipcountry,shipphonenumber,deliverystartdate,deliveryenddate,deliverytimezone,deliveryinstructions ) select
";
}
$sql.= "'{$parts[2]}','{$parts[1]}',";
for ($x=0;$x<$nb;$x++){
$sql.= "'{$v[$x]}',";
}
$sql=substr($sql, 0, strlen($sql)-1);        

if($parts[1]=='FBA'){
$sql.="where not exists (select null from af where amazonorderid = '{$v[0]}')";
}else if($parts[1]=='FBM'){
$sql.="where not exists (select null from am where orderid = '{$v[0]}')";  
}  
echo '<br>'.$sql;
dbquery2($sql);

} //end foreach data



}//end foreachfiles











dbquery("
insert into a (saleschannel,fulfilmentchannel,orderdate,orderid,qty,sku,contactbuyer,productdetails, totalprice)
select country,fulfilled,purchasedate,amazonorderid,quantityshipped,sku,buyername,productname,

  case when isnumeric(af.quantityshipped)=1 then CAST(af.quantityshipped as decimal(18,2)) else 0 end
* case when isnumeric(af.itemprice)=1 then CAST(af.itemprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.itemtax)=1 then CAST(af.itemtax as decimal(18,2)) else 0 end
+ case when isnumeric(af.shippingprice)=1 then CAST(af.shippingprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.shippingtax)=1 then CAST(af.shippingtax as decimal(18,2)) else 0 end
+ case when isnumeric(af.giftwrapprice)=1 then CAST(af.giftwrapprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.giftwraptax)=1 then CAST(af.giftwraptax as decimal(18,2)) else 0 end


from af
where
af.merchantorderid='' 
and
not exists (select 1 from a where a.orderid = af.amazonorderid )
");



dbquery("
insert into a (saleschannel,fulfilmentchannel,orderdate,orderid,qty,sku,contactbuyer,productdetails, totalprice)
select country,fulfilled,shipmentdate,amazonorderid,quantityshipped,sku,buyername,productname,

  case when isnumeric(af.quantityshipped)=1 then CAST(af.quantityshipped as decimal(18,2)) else 0 end
* case when isnumeric(af.itemprice)=1 then CAST(af.itemprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.itemtax)=1 then CAST(af.itemtax as decimal(18,2)) else 0 end
+ case when isnumeric(af.shippingprice)=1 then CAST(af.shippingprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.shippingtax)=1 then CAST(af.shippingtax as decimal(18,2)) else 0 end
+ case when isnumeric(af.giftwrapprice)=1 then CAST(af.giftwrapprice as decimal(18,2)) else 0 end
+ case when isnumeric(af.giftwraptax)=1 then CAST(af.giftwraptax as decimal(18,2)) else 0 end


from af
where
af.merchantorderid!='' 
and
not exists (select 1 from a where a.orderid = af.amazonorderid )
");

dbquery("
insert into a (saleschannel,fulfilmentchannel,orderdate,orderid,qty,sku,contactbuyer,productdetails, totalprice)
select country,fulfilled,purchasedate,orderid,quantitypurchased,sku,buyername,productname,

  case when isnumeric(am.quantitypurchased)=1 then CAST(am.quantitypurchased as decimal(18,2)) else 0 end
* case when isnumeric(am.itemprice)=1 then CAST(am.itemprice as decimal(18,2)) else 0 end
+ case when isnumeric(am.itemtax)=1 then CAST(am.itemtax as decimal(18,2)) else 0 end
+ case when isnumeric(am.shippingprice)=1 then CAST(am.shippingprice as decimal(18,2)) else 0 end
+ case when isnumeric(am.shippingtax)=1 then CAST(am.shippingtax as decimal(18,2)) else 0 end


from am
where
not exists (select 1 from a where a.orderid = am.orderid )
");

dbquery("update a set orderdate=convert(varchar(10),orderdate,120)");
dbquery("update a set fulfilmentchannel='Amazon' where fulfilmentchannel='FBA'");
dbquery("update a set fulfilmentchannel='Merchant' where fulfilmentchannel='FBM'");





  
?>

Open in new window

0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 17

Accepted Solution

by:
Jesse Houwing earned 2000 total points
ID: 34328983
The extended information on your error is, that it's an ACCESS_VIOLATION, which is what c0000005 stands for.

It means the code is trying to access memory that is not/no longer appointed to that process.

It looks like you're using a pretty old version of PHP 5.2.6.6, while 5.3.4 is already available and looking at the changelog, there have been multiple fixes/changes on both performance and bug of scandir, which would be the thing I'd guess is causing your issues. My guess here is that you're using dbquery in other scripts as well...

On the other hand, others are experiencing similar errors, because MySQL support wasn't enabled in their php.ini:
http://serverfault.com/questions/99842/php-has-encountered-an-access-violation-at
0
 

Author Closing Comment

by:rgb192
ID: 34354910
thanks
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question