【发布时间】:2019-11-27 12:19:07
【问题描述】:
这是我要查询的函数
function getUser($user_id){
global $db;
$query="select * from users WHERE user_id='$user_id'";
$res=mysqli_query($db, $query);
$res=mysqli_fetch_assoc($res);
file_get_contents($res);
file_put_contents('result22.txt', $res.PHP_EOL,FILE_APPEND);
}
这是我的情况,通过消息发送
case'information':{
$Stock=getUser($user_id)['Stock'];
$invited=getUser($user_id)['invited'];
$msg=urlencode("$invited\n\n$Stock");
send_message($user_id,$msg);
}
break;
以上导致以下异常:
块引用 file_get_contentshttps://api.telegram.org/bot984745149:AAH_g_Zuo9T****SDlS6_W7aISlsRAuCWY/sendMessage?chat_id=129372728&text=%0A%0A:打开流失败:HTTP 请求失败! HTTP/1.1 400 错误请求 在第 63 行的 /home/v/public_html/New/bot.php PHP 警告:file_get_contents() 期望参数 1 是有效路径,数组在第 116 行的 /home/v/public_html/New/bot.php 中给出 PHP 警告:file_get_contents() 期望参数 1 是有效路径,数组在 /home/v/public_html/New/bot.php 第 116 行给出
【问题讨论】:
-
“警告:file_get_contents() 期望参数 1 是有效路径,给定数组” - 有什么不清楚的地方?
-
(虽然你会在同一个调用中同时收到这两个错误,但这是没有意义的。)
-
检查输出:mysqli_fetch_assoc($res);功能:file_get_contents() 不喜欢你传递给它的参数。
-
“HTTP 请求失败! HTTP/1.1 400 Bad Request” - 然后在浏览器中调用相同的 URL,看看会得到什么结果 - 那里可能有一条错误消息。
标签: php telegram telegram-bot