Solved

sometimes this file runs, other times it crashes fastcgi

Posted on 2010-11-20
4
198 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
4 Comments
 
LVL 17

Accepted Solution

by:
ToAoM earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

705 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now