gpt4 book ai didi

php - 无限循环?遗漏了什么?我不知道发生了什么错误: 500 time out (Shouldn't be happening)

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

我正在尝试创建一个 PHP 脚本,它将分解一个 Json 文件,对其进行排序并将其发送到数据库,但是我不明白为什么会发生这种情况:我曾经收到一条错误消息,说我超出了 RAM PHP 的限制(将其设置为无限制),但现在我收到超时错误。我有一种感觉,这是我的代码,而不是服务器,但我没有看到任何错误,而且 while 循环不是无限循环。

<?php

//Set Ram Limit to Unlimited
ini_set('memory_limit', '-1');

//Improper Variables.
$tags = '';
$minTags = 1;
$value = '';

//Initialize Database Variables.
$host = 'localhost';
$username = 'icangame_dataa';
$password = '**********************************';
$dbname = 'icangame_data';

//Get Game Content
$linkFolder = $_POST['linkToFile'];
$file = '../games/'.$linkFolder.'/__metadata__.json';
$json = json_decode(file_get_contents($file), true);

//Take Apart the JSon
$width = $json['width'];
$height = $json['height'];
$author = $json['author'];
$thumbnail_url = $json['thumbnail_url'];
$description = $json['description'];
$controls = $json['controls'];
$developer = $json['developer'];
$name = $json['name'];
$developer_url = $json['developer_url'];
$tagsArray = $json['tags'];

//Process My Tags
$tagsNum = count($tagArray);

while ($minTags > $tagsNum)
{

$tagsTricky = "'.tags.'";
$minTagsTricky = "'".$minTags."'";
$value = $json[$tagsTricky[$minTags]];
$tags.=$value.' ';
$minTags++;

}

//Database Connection
$myCon = mysqli_connect($host, $username, $password, $dbname);

if (mysqli_connect_errno($myCon))
{

echo "Error Connection:".mysqli_connect_error();

}

//Checking if Item already exists.
$gameItem = mysqli_query($con,"SELECT $name FROM gameList");

if (!$gameItem == $name)
{

//Sending Data to Database.
mysqli_query($myCon, "INSERT INTO gameList (width, height, author, thumbnail_url, description, controls, developer, name, developer_url, tags)
VALUES ('$width', '$height', '$author', '$thumbnail_url', '$description', '$controls', '$developer', '$name', '$developer_url', '$tags')");

}
else
{

echo "Item ".$name." already exists! Sorry, someone beat you to it. ;c";

}



?>

最佳答案

如果条件为

while ($minTags > $tagsNum) 

true并且进入循环体,然后

$minTags++;

将确保下一次迭代时条件也为true,因为$tagsNum在循环体中未被修改。你有一个无限循环。

关于php - 无限循环?遗漏了什么?我不知道发生了什么错误: 500 time out (Shouldn't be happening),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17581554/

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