gpt4 book ai didi

php - 为什么这个 PHP 脚本显示 ' Webpage Not Available '

转载 作者:行者123 更新时间:2023-11-29 12:50:38 25 4
gpt4 key购买 nike

我不确定为什么当我使用 XAMPP 服务器访问页面时,以下简短的 PHP 脚本在 Chrome 中显示“网页不可用”。我已将 error_reporting 设置为 = E_ALL ^ E_DEPRECATED - 但是我没有生成任何错误。

我以前从未遇到过此问题,页面无法加载,至少会显示一些错误...

请参阅下面的代码:

PHP 和 MYSQL

$sql = "SELECT * from product WHERE brand_id NOT IN ('53', '10', '45', '29', '249')";
$result = mysql_query($sql) or die ( mysql_error() );

// load all stock
while ($line = mysql_fetch_assoc($result) )
{

// Contents of WHILE LOOP

// Size array to loop through when checking quantity
$con_size = array (35,355,36,365,37,375,38,385,39,395,40,405,41,415,42,425,43,435,44,445,45,455,46,465,47,475,48,485);
$arrayLength_uk=count($con_size);

for($x=0;$x<$arrayLength_uk;$x++)
{

// check if size is available
if($line['quantity_c_size_'.$con_size[$x].'_con_b'] > 0 )
{

$quantity = $line['quantity_c_size_'.$con_size[$x].'_con_b'];

$sql = "UPDATE product
SET quantity_c_size_$con_size[$x] = $quantity,
quantity_c_size_$con_size[$x]_con_b = 0
WHERE quantity_c_size_$con_size[$x]_con_b > 0";

$result = mysql_query($sql);

if ($result)
{
echo "Stock Updated";
}
else
{
echo "Something went wrong";
}
}
}
}

有人可以建议吗?谢谢。

已解决

我解决了这个问题 - 这似乎是这个 while($line = mysql_fetch_assoc($result) ) 的问题 - 我改为 mysql_fetch_array

新代码

$sql = "SELECT * from product WHERE brand_id NOT IN ('53', '10', '45', '29', '249') AND active='on'";
$result = mysql_query($sql) or die ( mysql_error() );

// load all stock
while ($line = mysql_fetch_array($result))
{

/*
* Continental Sizes
*
*/


//Possible size array to loop through when checking quantity
$con_size = array (35,355,36,365,37,375,38,385,39,395,40,405,41,415,42,425,43,435,44,445,45,455,46,465,47,475,48,485);
$arrayLength_uk=count($con_size);

for($x=0;$x<$arrayLength_uk;$x++)
{

// check if size is available
if($line['quantity_c_size_'.$con_size[$x].'_chain'] > 0 )
{

$quantity = $line['quantity_c_size_'.$con_size[$x].'_chain'];
$product_id = $line ['product_id'];

echo $quantity;

$data = "UPDATE product
SET quantity_c_size_$con_size[$x]_con_c = $quantity,
quantity_c_size_$con_size[$x]_chain = 0
WHERE product_id = '$product_id'";

$result2 = mysql_query($data);

if ($result2)
{
echo 'Stock Updated <br />';
}
else
{
echo 'Something went wrong <br />';
}

}
}
}

感谢所有回复的人。

最佳答案

问题出在这一行:

$result = mysql_query($sql);

您在内部循环中更改用于计算外部循环迭代的$result变量

你可能应该改变:

$result = mysql_query($sql);

if ($result)
{

进入

$result2 = mysql_query($sql);

if ($result2)
{

关于php - 为什么这个 PHP 脚本显示 ' Webpage Not Available ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24802119/

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