gpt4 book ai didi

php - 是什么导致了这个 modx 错误?

转载 作者:行者123 更新时间:2023-11-29 23:25:46 24 4
gpt4 key购买 nike

我遇到了最奇怪的错误,modx 站点中的一个简单的导入/导出脚本导致了一些非常奇怪的行为。这是脚本:

<?php
/**
* Project: httpdocs
* Created by: BigBlock Studios .
* User: Sean Kimball
* Date: 16/07/14
* Time: 2:44 PM
*/

$remoteip = $_SERVER['REMOTE_ADDR'];

$allowedips = array('xxx.xxx.xxx.xxx','xxx.xxx.xxx.xxx');

if(!in_array($remoteip, $allowedips)){ echo 'denied'; return; }

error_reporting(E_ALL);
ini_set('display_errors', '1');

$mshost = 'xxx.xxx.xxx.xxx';
$msdb = 'msdb';
$msuser = 'msuser';
$mspass = 'mspass';

$myhost = 'xxx.xxx.xxx.xxx';
$mydb = 'mydb';
$myuser = 'myuser';
$mypass = 'mypass';
$mytable = 'modx_gssi_inventory_data';
$gatable = 'modx_gssi_inventory_gage';
$n = 100;

$query ="select TOP $n RECORDNUMBER,RESERVECUST,TAGNUMBER,ORIGINALPRICE,WIDTH,LENGTH,SCALEWGT,MINGAGE,IBLNUMBER,MILLTAGNO,VISUALDESC,FINISH,LOCATION,PONUMBER,VENDORNUMBER,STORAGETAGNO,PRODCLASS,RELEASENUMBER, PURCHASEDESC,NCTCT,STATUS,SALESDESC,CUSTOMERPONUMBER,PLANTLOCATION,LINEALFT,PIW from dbo.POInvWrk WHERE STATUS = 'A' AND RESERVECUST = ''";

$connection = mssql_pconnect($mshost, $msuser, $mspass);

if(!$connection){echo 'Could not connect to SQL server';}

if (!mssql_select_db($msdb, $connection)) {echo 'Unable to select MSSQL database!';}

$results = mssql_query($query, $connection);

// echo mssql_num_rows($results);

if (!mssql_num_rows($results)) {

echo 'No MSSQL records found';

} else {

$conn = mysql_connect($myhost, $myuser, $mypass);
mysql_select_db($mydb, $conn);
if (!$conn) { echo 'Failed to connect to MySQL'; }
mysql_query("delete from $mytable")or die(mysql_error()."delete failed");

while ($result = mssql_fetch_array($results, MSSQL_BOTH)) {

$TAGNUMBER = trim(mysql_real_escape_string($result['TAGNUMBER']));
$NCTCT = trim(mysql_real_escape_string($result['NCTCT']));
$PRODCLASS = trim(mysql_real_escape_string($result['PRODCLASS']));
$FINISH = trim(mysql_real_escape_string($result['FINISH']));
$MINGAGE = trim(mysql_real_escape_string($result['MINGAGE']));
$WIDTH = trim(mysql_real_escape_string($result['WIDTH']));
$LENGTH = trim(mysql_real_escape_string($result['LENGTH']));
$SCALEWGT = trim(mysql_real_escape_string($result['SCALEWGT']));
$RESERVECUST = trim(mysql_real_escape_string($result['RESERVECUST']));
$PONUMBER = trim(mysql_real_escape_string($result['PONUMBER']));
$PLANTLOCATION = trim(mysql_real_escape_string($result['PLANTLOCATION']));
$LOCATION = trim(mysql_real_escape_string($result['LOCATION']));
$STORAGETAGNO = trim(mysql_real_escape_string($result['STORAGETAGNO']));
$VENDORNUMBER = trim(mysql_real_escape_string($result['VENDORNUMBER']));
$ORIGINALPRICE = trim(mysql_real_escape_string($result['ORIGINALPRICE']));
$MILLTAGNO = trim(mysql_real_escape_string($result['MILLTAGNO']));
$RELEASENUMBER = trim(mysql_real_escape_string($result['RELEASENUMBER']));
$IBLNUMBER = trim(mysql_real_escape_string($result['IBLNUMBER']));
$VISUALDESC = trim(mysql_real_escape_string($result['VISUALDESC']));
$PURCHASEDESC = trim(mysql_real_escape_string($result['PURCHASEDESC']));
$RECORDNUMBER = trim(mysql_real_escape_string($result['RECORDNUMBER']));
$STATUS = trim(mysql_real_escape_string($result['STATUS']));
$SALESDESC = trim(mysql_real_escape_string($result['SALESDESC']));
$CUSTOMERPONUMBER = trim(mysql_real_escape_string($result['CUSTOMERPONUMBER']));
$LINEALFT = trim(mysql_real_escape_string($result['LINEALFT']));
$PIW = trim(mysql_real_escape_string($result['PIW']));

$GA = mysql_query("select ga from $gatable where $MINGAGE >= min and $MINGAGE <= max;");
echo "select ga from $gatable where $MINGAGE >= min and $MINGAGE <= max = $GA <br />";
$timestamp = time();

$insert = "insert into $mytable (`timestamp`,
tag_no, classification, grade, finish,
gage, ga, width, `length`,
scale_wgt, cust, po_num, plant,
location, storage_tag_no, vendor_number, original_price,
mill_tag_no, release_number, ibl_number, visual_desc,
purchase_desc, mssql_id, status, sales_desc,
customer_po_num, nctct, linealft, piw)
values (
'$timestamp',
'$TAGNUMBER',
'$NCTCT',
'$PRODCLASS',
'$FINISH',
'$MINGAGE',
'$GA',
'$WIDTH',
'$LENGTH',
'$SCALEWGT',
'$RESERVECUST',
'$PONUMBER',
'$PLANTLOCATION',
'$LOCATION',
'$STORAGETAGNO',
'$VENDORNUMBER',
'$ORIGINALPRICE',
'$MILLTAGNO',
'$RELEASENUMBER',
'$IBLNUMBER',
'$VISUALDESC',
'$PURCHASEDESC',
'$RECORDNUMBER',
'$STATUS',
'$SALESDESC',
'$CUSTOMERPONUMBER',
'$NCTCT',
'$LINEALFT',
'$PIW'

);";

mysql_query($insert)or die(mysql_error()."insert failed".$insert);

}

//$mysqli->close();
}


?>

问题是它没有填充导入中的“GA”字段,其他一切都运行正常。

我回显选择“GA”值的脚本的行输出记录如下:

select ga from modx_gssi_inventory_gage where 0.182 >= min and 0.182 <= max = Resource id #10 

如果我对 modx_gssi_inventory_gage 表运行查询,我得到的预期结果是一个整数,而不是“Resource id #10”

  • 请注意,该脚本甚至不知道 modx 并且不应返回任何资源 ID。
  • 它是独立运行的,没有什么叫它只是将浏览器指向脚本。
  • 我可以从一个甚至没有安装 modx 的域运行它,它仍然会带着这种奇怪的情况回来。

对于这是怎么回事有什么想法吗???

最佳答案

$GA = mysql_query("select ga from $gatable where $MINGAGE >= min and $MINGAGE <= max;");

这应该返回 resource ,确实如此。您需要先处理该结果,然后才能有效地使用它。


$row = mysql_fetch_assoc($GA);
$GA = $row['ga'];

参见PHP's关于它的页面。

关于php - 是什么导致了这个 modx 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26983241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com