Solved

sometimes this file runs, other times it crashes fastcgi

Posted on 2010-11-20
4
199 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:
Jesse Houwing 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to create a scatter graph with straight lines 6 26
simplest php form 3 57
Php pie charts 3 26
Facial recognition to look through the whole database for a person 3 39
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

914 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

14 Experts available now in Live!

Get 1:1 Help Now