Solved

sometimes this file runs, other times it crashes fastcgi

Posted on 2010-11-20
4
203 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 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send email using HTML and PHP in separate file 5 40
$_GET call between URL 3 41
Hta File displays dynamic File names 4 46
add if statement powershell 8 23
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…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

749 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