脚本死了但错误日志中没有错误 [英] script dies yet there are no errors in error log

查看:55
本文介绍了脚本死了但错误日志中没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



关于这个脚本的任何内容在资源或执行时间方面看起来都很昂贵吗?该脚本在处理了大约20或25个
的数字后死亡,但它在错误日志中没有留下任何错误。这是在服务器

上处理相当苛刻的网站。在php.ini中,默认值都是相当高的:脚本运行时间为180秒,而且他们可以使用
多达256兆内存。


这个脚本的输入来自表单中的textarea,而

输入也不是更简单,只是一堆UPC代码,每行一个:

881034146533x

881034146533xx

881034146533xxx

881034146533xxxx

881034146533xxxxx

881034146533xxxxxx

881034146533xxxxxxx

881034146533xxxxxxxx

881034146533xxxxxxxxx

881034146533xxxxxxxxxx

881034146533xxxxxxxxxxx

881034146533xxxxxxxxxxxx

881034146533xxxxxxxxxxxxx

881034146533xxxxxxxxxxxxxx

881034146533xxxxxxxxxxxxxxx

881034146533xxxxxxxxxxxxxxxx

881034146533xxxxxxxxxxxxxxxxx

881034146533xxxxxxxxxxxxxxxxxx

给出15个这样的数字,脚本运行正常。但是考虑到200个这样的数字,

它在处理了大约10个数字之后就死了。


据说这个代码是多年前写的,早在2002年,但是,据说
,这个剧本的问题(它已经死了)最近只开始了

。据说,没有对剧本进行任何修改,只是简单地说b $ b开始死了。 (可悲的是,该网站的代码最近才进入了

Subversion,我最近才加入该项目,所以我没办法

评估这些声明。)

< ;?

set_time_limit(0);


require(" include_header.php");


$ dbh = mysql_pconnect(" xxxxx"," xxxxx"," xxxxx");


mysql_select_db(" alb") ;


$ upc_input = $ _POST [" upc_input"];


if($ upc_input){

$ pieces = explode(" \ n",$ upc_input);


$ count = 0;

$ log_file = dirname ($ _SERVER [" SCRIPT_FILENAME"])。''/ logs / album_removals.log'';

$ fp = fopen($ log_file,''a +'');

while($ upc = $ pieces [$ count]){

$ upc = trim($ upc);

fwrite($ fp,$ upc。" ; \ n");

echo"删除UPC / ISRC代码:$ upc< br /> \ n" ;;

$ query ="从'albums`中选择id,其中UPPER(upc_id)=

''" .strtoupper($ upc)。"''" ;;

$ result = mysql_query($ query);


if(mysql_num_rows($ result)){

// 10-15-08 - 下一行假设只有

//每个UPC只有一条记录。由于我不知道足够争辩,我会

//假设现在必须这样。我想知道导入脚本是否在UPC上强制执行唯一性? --LK

$ row = mysql_fetch_array($ result);

$ id = $ row [" id"];


/ *我们将此更改为status =''4''表示完全删除。

当我们运行时,只会检查status =''3'的值

我们的go_live.php cronjob在某些日期设置专辑

* /

$ query2 ="更新专辑SET status =''4''其中id = "。$ id;

$ result2 = mysql_query($ query2);

$ numUpdated = mysql_affected_rows($ dbh);

if( $ numUpdated){

echo"更改了UPC $ id的相册状态< br /> \ n";

}其他{

// echo"无法更改UPC $ id的专辑状态< br /> \ n" ;;

//

// 10- 15-08 - 当一些职员将两个相同的UPC放入

时会发生什么?我不想
//想要给出一个失败的东西信息。让我们检查状态。

如果它等于4

//那么记录已经成功更新。如果没有,那么我们可以

//给出失败的消息。

$ queryStatusCheck =" SELECT status FROM album WHERE id =' '$ id''" ;;

$ resultStatusCheck = mysql_query($ queryStatusCheck);

$ rowStatusCheck = mysql_fetch_assoc($ resultStatusCheck);

$ status = $ rowStatusCheck [" status"];

if($ status == 4){

echo"相册状态已更新< br /> \ n" ;;

}其他{

echo&'无法更改UPC $ upc的专辑状态(专辑$ id)

< br /> \ n";

}

}


$ query3 =" update tracks SET status =''4''其中album_id ="。$ id;

$ result3 = mysql_query($ query3);

$ numUpdated = mysql_affected_rows($ dbh);

if($ numUpdated){

echo"更改了UPC $ id< br />< br /> \ n \的专辑状态n" ;;

}否则{

//回声无法更改UPC $ id的跟踪专辑状态< br

/>< br /> \ n \ n" ;;

/ /

// 10-15-08 - 当一些职员将两个相同的UPC放入

时会发生什么?我不想
//想要给出一个失败的东西信息。让我们检查状态。

如果它等于4

//那么记录已经成功更新。如果没有,那么我们可以

//给出失败的消息。

$ queryStatusCheck =" SELECT status FROM tracks WHERE

album_id =''$ id''" ;;

$ resultStatusCheck = mysql_query($ queryStatusCheck);

$ rowStatusCheck = mysql_fetch_assoc($ resultStatusCheck);

$ status = $ rowStatusCheck [" status"];

if($ status == 4){

echo" Track album状态已更新< br /> \ n" ;;

}其他{

echo"无法更改UPC $ upc的专辑状态(专辑

$ id)< br /> \ n" ;;

}

}

}其他{

$ query ="从`tracks`中选择id,其中UPPER(isrc_id)=

''" .strtoupper($ upc)。"''" ;;

$ result = mysql_query($ query);


if(mysql_num_rows($ result)){

$ row = mysql_fetch_array($ result);

$ id = $ row [" id"];

$ query 2 =更新曲目SET status =''4''其中id ="。$ id;

$ result2 = mysql_query($ query2);

echo" ;已成功删除并重建Track Id"。$ id;


} else {

echo"无法找到代码作为专辑UPC或轨道ISRC" ;;

}


}

echo"< br />" ;;

$ count ++;

}


fclose($ fp);

?>




Does anything about this script look expensive, in terms of resources or
execution time? This script dies after processing about 20 or 25
numbers, yet it leaves no errors in the error logs. This is on a server
that handles a fairly demanding site. The defaults, in php.ini, have all
been cranked fairly high: scripts get 180 seconds to run, and they can
have as much as 256 megs of RAM.

The input for this script is coming from a textarea in a form, and the
input could not be more simple, just a bunch of UPC codes, one per line:
881034146533x
881034146533xx
881034146533xxx
881034146533xxxx
881034146533xxxxx
881034146533xxxxxx
881034146533xxxxxxx
881034146533xxxxxxxx
881034146533xxxxxxxxx
881034146533xxxxxxxxxx
881034146533xxxxxxxxxxx
881034146533xxxxxxxxxxxx
881034146533xxxxxxxxxxxxx
881034146533xxxxxxxxxxxxxx
881034146533xxxxxxxxxxxxxxx
881034146533xxxxxxxxxxxxxxxx
881034146533xxxxxxxxxxxxxxxxx
881034146533xxxxxxxxxxxxxxxxxx
Given 15 such numbers, the script does fine. But given 200 such numbers,
it dies after processing about 10 numbers.

Supposedly, the code was written many years ago, back in 2002, and yet,
supposedly, the problem with this script (that it dies) only started
recently. Supposedly, no changes were made to the script, it simply
started to die. (Sadly, the code for the site was only recently put into
Subversion, and I only recently joined the project, so I''ve no way to
evaluate these claims.)
<?
set_time_limit(0);

require ("include_header.php");

$dbh = mysql_pconnect("xxxxx", "xxxxx", "xxxxx");

mysql_select_db("alb");

$upc_input = $_POST["upc_input"];

if ($upc_input) {

$pieces = explode("\n", $upc_input);

$count = 0;
$log_file = dirname($_SERVER["SCRIPT_FILENAME"]).''/logs/album_removals.log'';
$fp = fopen($log_file, ''a+'');
while ($upc = $pieces[$count]) {
$upc = trim($upc);
fwrite($fp, $upc."\n");
echo "Removing UPC/ISRC Code: $upc <br />\n";
$query = "select id from `albums` where UPPER(upc_id) =
''".strtoupper($upc)."''";
$result = mysql_query($query);

if (mysql_num_rows($result)) {
// 10-15-08 - this next line makes the assumption that there can
only be
// one record for each UPC. Since I don''t know enough to argue, I''ll
// assume this must be true for now. I wonder if the import scripts
// enforce uniqueness on the UPC? --LK
$row = mysql_fetch_array($result);
$id = $row["id"];

/* We changed this to status=''4'' to indicate full removal.
Only values of status=''3'' will be checked when we run
our go_live.php cronjob to set albums live on certain dates
*/
$query2 = "update albums SET status=''4'' where id=".$id;
$result2 = mysql_query($query2);
$numUpdated = mysql_affected_rows($dbh);
if ($numUpdated) {
echo "Changed album status for UPC $id <br />\n";
} else {
// echo "Failed to change album status for UPC $id <br />\n ";
//
// 10-15-08 - what happens when some staffer puts the same UPC in
twice? I don''t
// want to give a "fail" message. Let''s check to see the status.
If it equals 4
// then the record has already been successfully updated. If not,
then we can
// give a fail message.
$queryStatusCheck = "SELECT status FROM albums WHERE id=''$id'' ";
$resultStatusCheck = mysql_query($queryStatusCheck);
$rowStatusCheck = mysql_fetch_assoc($resultStatusCheck);
$status = $rowStatusCheck["status"];
if ($status == 4) {
echo "Album status already updated <br />\n ";
} else {
echo "Failed to change album status for UPC $upc (album $id)
<br />\n ";
}
}

$query3 = "update tracks SET status=''4'' where album_id=".$id;
$result3 = mysql_query($query3);
$numUpdated = mysql_affected_rows($dbh);
if ($numUpdated) {
echo "Changed tracks album status for UPC $id <br /><br />\n\n ";
} else {
// echo "Failed to change tracks album status for UPC $id <br
/><br />\n\n ";
//
// 10-15-08 - what happens when some staffer puts the same UPC in
twice? I don''t
// want to give a "fail" message. Let''s check to see the status.
If it equals 4
// then the record has already been successfully updated. If not,
then we can
// give a fail message.
$queryStatusCheck = "SELECT status FROM tracks WHERE
album_id=''$id'' ";
$resultStatusCheck = mysql_query($queryStatusCheck);
$rowStatusCheck = mysql_fetch_assoc($resultStatusCheck);
$status = $rowStatusCheck["status"];
if ($status == 4) {
echo "Track album status already updated <br />\n ";
} else {
echo "Failed to change track album status for UPC $upc (album
$id) <br />\n ";
}
}
} else {
$query = "select id from `tracks` where UPPER(isrc_id) =
''".strtoupper($upc)."''";
$result = mysql_query($query);

if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
$id = $row["id"];
$query2 = "update tracks SET status=''4'' where id=".$id;
$result2 = mysql_query($query2);
echo "Successfully removed and rebuilt Track Id ".$id;

} else {
echo "Could not find Code as an Album UPC or a Track ISRC";
}

}
echo "<br />";
$count++;
}

fclose($fp);
?>




推荐答案

dbh = mysql_pconnect(" xxxxx"," xxxxx"," xxxxx") ;


mysql_select_db(" alb");

dbh = mysql_pconnect("xxxxx", "xxxxx", "xxxxx");

mysql_select_db("alb");


upc_input =
upc_input =


_POST [" upc_input"];


if(
_POST["upc_input"];

if (


这篇关于脚本死了但错误日志中没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆