SuperMar1o SuperMar1o - 2 years ago 326
PHP Question

PHP Script fopen failed to open stream: > Invalid argument Error

I am getting a warning.

Warning: fopen(76561197992146126 .txt): failed to open stream:
Invalid argument in C:\wamp\www\Download\t3.php on line 6

For anyone wondering, this is the contents of main.txt below (

$APIkey = 'APIKeyHere';
$file = file('C:\wamp\www\Download\main.txt');
foreach ($file as $link) {
$link2 = "" . $APIkey . "&SteamID=" . $link . "&format=json";
$downloaded = file_get_contents($link2);
$fh = fopen($link . ".txt", "a"); //or die("can't open file");
fwrite($fh, $downloaded);
echo "Finished";

If I replace "fopen($link . ".txt", "a")" with a static file-name it works. But I need $link to be the filename. It is imperative to my setup.

I am running Windows 7 x64 using WAMP 2.2 with PHP 5.4.3

Answer Source

Your link IDs have whitespace in them. Try adding $link = trim($link); before creating $link2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download