我试图执行一个查询并通过结果迭代.这些echo "<h1>" . $row["SummonerId"]. "</h1>";
作品将在页面上打印出来.但不知何故,这个错误发生在打印结果后:
致命错误:在字符串上调用成员函数fetch_assoc()
我看到很多类似的错误.但那些是on a non-object
和不是on string
.这个错误是什么?
这是我的代码:
$servername = "localhost:3307";
$username = "root";
$password = "";
$dbname = "st-datacollector";
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "SELECT * FROM summoner";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<h1>" . $row["SummonerId"]. "</h1>";
$summonerId = $row["SummonerId"];
$url = "https://euw.api.pvp.net/api/lol/euw/v1.3/game/by-summoner/" . $summonerId . "/recent?api_key=" . $api_key;
$result = file_get_contents($url);
$resultJSON = json_decode($result);
foreach($resultJSON_decoded->games as $game){ …
Run Code Online (Sandbox Code Playgroud) 我想用Graphics2D在Java中使用Color 2 Ovals.Oval1(point
)绿色和椭圆形2(point2
)蓝色.问题是Oval2变成绿色而Oval1变成黑色.有人知道问题是什么吗?
这是SSCCE:
GameView.java
import javax.swing.JFrame;
import stackoverflow.GameView;
public class GameView extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
private Game game = new Game();
public GameView(){
JFrame gameFrame = new JFrame("Game");
gameFrame.setSize(500, 300);
gameFrame.setVisible(true);
gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gameFrame.add(game);
game.runGame();
}
public static void main(String[] args) throws InterruptedException {
new GameView();
}
}
Run Code Online (Sandbox Code Playgroud)
Game.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import stackoverflow.Point;
public class Game extends JPanel{
/**
*
*/
private static …
Run Code Online (Sandbox Code Playgroud)