fopen()希望参数1是一条有效路径。

时间:2022-04-07 18:42:48

Never see this error befor now! I'm very confused... I'm using only this part of code for testing what i want to get:

永远不要看到这个错误!我很困惑……我只使用这一部分代码来测试我想要得到什么:

<?php
if(isset($_GET['id'])) {
    $index = $_GET['id'];
    $nick = $_GET['nck'];

    $db_visited = file("db.txt");
    $open = fopen($db_visited, "w");
    fwrite($open, $index."\n");
    foreach ($db_visited as $line) { fwrite( $open, "$line"); }
    fclose($open);
    //header("location: https://www.facebook.com/".$nick);
}
?>
<?php
$dblines = file("db_friends.txt");
foreach($dblines as $key => $profile) {
list($name, $nick, $num_id) = explode("|", $profile);
?>
<div id="fr_slot">
    <a href="<?= $_SERVER['PHP_SELF']; ?>?nck=<?= $nick; ?>&id=<?= $key ?>" target="_tab"><?= $name ?></a>
</div>

<?php } ?>

I'm wondering what is wrong at fopen() for expects parameter 1! In this case, really, i don't understand... Please, help me! Thanks a lot!

我想知道fopen()对于预期参数1有什么问题!在这种情况下,真的,我不明白……请帮帮我!谢谢!

2 个解决方案

#1


4  

file read the file and return an array

文件读取文件并返回一个数组。

fopen need the path to your file, and $db_visited isn't the path but an array

fopen需要路径到您的文件,而$db_visited不是路径,而是一个数组。

#2


3  

$db_visited is an array since file() returns an array. If you're looking to open the file, change:

$db_visited是一个数组,因为file()返回一个数组。如果你想打开文件,改变:

$open = fopen($db_visited, "w");

To:

:

$open = fopen("db.txt", "w");

#1


4  

file read the file and return an array

文件读取文件并返回一个数组。

fopen need the path to your file, and $db_visited isn't the path but an array

fopen需要路径到您的文件,而$db_visited不是路径,而是一个数组。

#2


3  

$db_visited is an array since file() returns an array. If you're looking to open the file, change:

$db_visited是一个数组,因为file()返回一个数组。如果你想打开文件,改变:

$open = fopen($db_visited, "w");

To:

:

$open = fopen("db.txt", "w");