file_get_contents issue php level server

Status
Not open for further replies.

Twysted

New Member
Messages
27
Reaction score
0
Points
3
can someone tell me why file_get_contents isn't working for me on the level server
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. How are you using it (ie, post some code)
2. Any error messages?
 

Twysted

New Member
Messages
27
Reaction score
0
Points
3
PHP:
<?php
$url="http://thebot.net/api/post2.php";
$c = file_get_contents($url);
$c = utf8_encode($c);
$r = json_decode($c, true);

$user=$r->{'username'};
$gr1=$r->{'usergroup'};
$gr2=$r->{'secondary'};
$posts=$r->{'posts'};

//$action=switch($gr2);
if(is_array($gr2) && !(in_array("Coder",$gr2)))
{
    echo '<a href="https://www.coderprofile.com/coder/Enterprise-PHP" target="_blank"><img src="https://www.coderprofile.com/images/badges/follow-me/style-2/user-bar-1.png" /></a>';
}
if(isset($gr1) && $gr1 == 'TBN Member'))
{
    echo '<a href="http://thebot.net/payments.php" target="_blank">click here to remove this ad</a> sponsored by TBN';
}
?>

there are no errors. just a blank page.
 

pnk

New Member
Messages
22
Reaction score
1
Points
3
http://thebot.net/api/post2.php returns -> "Please Post On TBN", and the script is then encoding this string into $c again. After that, you are decoding it as json source. I believe this is not correct. for the blank page issue. Try commenting out all lines and then relieving one by one each line while testing.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Agree with pnk. The problem seems to be that the URL you are requesting is not what you were expecting.

After the second line,

$c = file_get_contents($url);

Add

echo $c ;

and see what the function returns and compare that with what your browser returns for that URL.
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
also I see one extra " ) " on the end of this line:
Code:
if(isset($gr1) && $gr1 == 'TBN Member'))
 

Twysted

New Member
Messages
27
Reaction score
0
Points
3
you guys are not seeing the url because you are not logged into that site. it is an api to a forum. this is for a dynamic signature for that forum. Thank you bdistler, i did not see that, and thus why i need someone else to look at it for me. I should prolly turn on error reporting as well.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I we can't see whatever you are trying to get from that URL because we are not logged id, how is your script supposed to?

And as I said, put an "echo" statement to show what your are getting back. Not after your run it through a dozen other functions, but right at the source.
 

Twysted

New Member
Messages
27
Reaction score
0
Points
3
I we can't see whatever you are trying to get from that URL because we are not logged id, how is your script supposed to?

And as I said, put an "echo" statement to show what your are getting back. Not after your run it through a dozen other functions, but right at the source.
my script can see it fine. its added to a white list. you can't see it cause you don't have access to it. it is a json record if that makes you feel any better.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Turn on error reporting. You're not getting output from your script.
 
Status
Not open for further replies.
Top