php - 不幸的是 PHP file_get_contents 不工作
问题描述
我正在尝试获取存储在数据库中的 url。我可以回显 url 但是当我尝试使用 file_get_contents 函数来获取页面时,它说failed to open stream: No such file or directory
用于从数据库中获取数据的 PHP 代码
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Job, Link FROM primarydata";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$job = $row["Job"];
$link = $row["Link"];
echo $job;
echo $link;
$htmlcontent = file_get_contents($link);
echo $htmlcontent;
}
} else {
echo "0 results";
}
$conn->close();
?>
我能够回显 URL,但在下一个链接中它不执行该file_get_contents
功能
解决方案
推荐阅读
- sql-injection - 当我选择 level=5 和 risk=3 时,SQLMap 需要很长时间
- c# - 如何将 json 映射到类模型?
- perl - 扫描一个大的 .gz 文件并将它的字符串从一个已知单词(在文件中重复)中拆分出来,并将所有拆分后的字符串保存在一个 .txt 文件中
- c# - 继承:无法从基类访问方法
- xamarin.forms - CrossGeolocator.Current.IsGeolocationEnabled 总是返回 false
- c++ - 启用 wordWrap 的 QLabel 的垂直大小
- entity-framework-core - 一个主键映射到多个表作为外键 EntityFrameworkCore
- python - 如何将参数的值列表添加到一组数据帧中,其中该参数对每个数据帧具有不同的值?
- php - 如何在 Laravel 中使用 OVH Api
- vuejs2 - 更改 props 时如何触发 AJAX 请求?