$drow = $query->fetch_assoc();Fatal error: Uncaught Error: Call to a member function fetch_assoc() on bool
时间: 2023-12-10 08:41:39 浏览: 31
这个错误通常表示查询失败,返回的是一个布尔值 false 而不是结果集对象。有几种可能的原因:
1. SQL 查询语句有误,无法正确执行;
2. 没有建立有效的数据库连接;
3. 查询语句执行时发生了错误,比如表不存在、字段名错误等;
4. 查询语句执行成功,但是没有符合条件的结果。
你可以尝试打印出 SQL 语句和错误信息,检查语句是否正确、连接是否有效,以及是否存在错误。例如:
```php
$query = $mysqli->query("SELECT * FROM my_table");
if ($query === false) {
echo "Error: " . $mysqli->error;
} else {
$drow = $query->fetch_assoc();
// do something with $drow
}
```
相关问题
#include <graphics.h> #include<conio.h> #include<cmath> class SineGraph{ protected: double A, w, b; public: SineGraph(double i, double j, double k) { i = A; j = w; k = b; } void drow() { for (int i = 0; i < 1000; ++i) { b += 0.1; if (b > 100) b = -100; cleardevice(); for (int x = 200; x < 400; ++x) { line(x, A * sin((w * x + b) + 200), x + 1, A* sin(w * (x + 1) + b) + 200); Sleep(30); } } } }; int main() { initgraph(640, 480,1); // 设置窗口大小为 640x480 SineGraph sg(100,0.05,10); sg.drow(); // 绘制正弦图形 _getch(); // 等待按键退出 closegraph(); // 关闭图形窗口 return 0; }
这段代码是使用 C++ 的 graphics.h 库绘制一个正弦图形。代码中定义了一个名为 SineGraph 的类,它有三个保护成员变量 A、w 和 b,代表正弦图形的振幅、频率和相位差。构造函数用来初始化这三个变量的值。
类中有一个名为 draw() 的成员函数,用于绘制正弦图形。在循环中,相位差 b 每次增加0.1,当 b 大于100时重新设置为-100。然后使用 graphics.h 库中的 line() 函数绘制一条条线段来表示正弦曲线,其中 x 坐标从200到400,y 坐标根据正弦函数计算得到。每绘制一条线段后,使用 Sleep() 函数暂停一段时间,以便观察图形的变化。
在主函数中,首先使用 initgraph() 函数初始化图形窗口的大小为640x480。然后创建一个 SineGraph 类的对象 sg,并调用其 draw() 函数来绘制正弦图形。最后使用 _getch() 函数等待按键,按下任意键后使用 closegraph() 函数关闭图形窗口,程序结束。
这段代码需要在支持 graphics.h 库的编译环境中运行,比如 Turbo C++。
Drow Ranger
Drow Ranger is a ranged agility hero in the popular online game Dota 2. She is known for her ability to deal massive physical damage from a distance, making her a formidable opponent in team fights and one-on-one battles. Her abilities include Frost Arrows, which slows enemies and deals bonus damage, Gust, which silences and pushes back enemies, Precision Aura, which grants bonus damage to nearby allied ranged heroes, and her ultimate Marksmanship, which increases her agility and grants bonus damage while disabling her Precision Aura. Drow Ranger is often played as a carry, meaning she focuses on farming gold and experience to become stronger and deal more damage later in the game.