file_get_contents() question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
OneEyedJack
Forum Newbie
Posts: 2
Joined: Wed Nov 17, 2010 1:38 pm

file_get_contents() question

Post by OneEyedJack »

This line works fine for me when I read the contents of the URL into a string

Code: Select all

$fname = file_get_contents('http://www.mydomain.com/ci/ci.php?/ch/b/02/972/L/0/M/0/1/972');
This one, which tries to add flexibility of changing some parameters yields the error below it.

Code: Select all

$modid = 972;
$filetoget = "'http://www.mydomain.com/ci/ci.php?/ch/b/02/" .$modid ."/L/0/M/0/1/" .$modid ."'";
$fname = file_get_contents($filetoget);
Error:
A PHP Error was encountered

Severity: Warning

Message: file_get_contents('http://www.mydomain.com/ci/ci.php?/ch/b ... /M/0/1/972') [function.file-get-contents]: failed to open stream: Permission denied
Am I missing something obvious.? The function seems to be interpreting the $fname variable correctly.

Jackl
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: file_get_contents() question

Post by AbraCadaver »

Get rid of the single quotes, what's that about?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
OneEyedJack
Forum Newbie
Posts: 2
Joined: Wed Nov 17, 2010 1:38 pm

Re: file_get_contents() question

Post by OneEyedJack »

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://www.mydomain.com/ci/ci.php?/ch/b ... /M/0/1/972) [function.file-get-contents]: failed to open stream: Permission denied
Losing the quotes simply results in the same error message except without the quotes.

Jack
Post Reply