This question already has answers here:
Why I'm getting 500 error when using file_get_contents(), but works in a browser?
(2 answers)
Closed 7 years ago.
I don't know why but I always got this error when I want to get PHP data with file_get_contents.
I have checked my PHP.ini and allow_url_fopen is: ON so that couldn't be the problem.
Here is the code I'm using:
$id='54352';
$url='http://www.google.com';
$data = file_get_contents('http://www.####.###/###.php?id='.$id.'&url='.urlencode($url));
var_dump($data);
I don't know what is going on here, I just get this error message and the value: bool(false).
I have also tried cURL, but it doesn't return ANY value to me.
Can anyone please help me?
Try something like:
$data = file_get_contents('http://www.####.###/###.php?id='.$id.'&url='.urlencode($url),true);
Related
This question already has answers here:
Why does var_dump show filename and line number?
(2 answers)
Closed 5 years ago.
so here in the below code im calling nytimes api
<?php
function rpnyt_article_get_result( $rpnyt_search , $rpnyt_key ){
$rpnyt_url = 'https://api.nytimes.com/svc/search/v2/articlesearch.json?q='.$rpnyt_search.'&api-key='.$rpnyt_key ;
$json_feed = wp_remote_get($rpnyt_url);
var_dump($json_feed[ 'body']);
}
?>
im getting response back as expected but that includes file url from where im calling this function like /home/ubuntu/XXXXXXXXX/xxxxxxxxxxxx/plugins/XXxxx/includes/rpnyt-news-content.php:8:(see image)
Try var_export() instead of var_dump().
http://php.net/manual/en/function.var-export.php
Consider using
echo(json_encode($your_thing));
This question already has answers here:
What is the difference between POST and GET? [duplicate]
(7 answers)
Closed 7 years ago.
I have no time and too tired to struggle with this, so I decided to ask here: I've created the file my.php which contains only:
<?php var_dump( $_POST ); ?>
And then I open the file using browser like this:
www.domain.com/my.php?post1=hey&post2=ho&post3=letsgo
And in the browser I have array(0) { } as a response.
Question: What could I possibly done wrong??
Thanks!
In URL are GET parameters, not POST.
echo $_GET['post1']; // hey
echo $_GET['post2']; // ho
echo $_GET['post3']; // letsgo
You cant pass POST variables through URL.
u r using GET method..
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
I am trying to put this line of code:
echo $row['url'];
between the quotations in this line of code:
$data = file_get_contents ("");
I have a link saved in my database which I want to be displayed between those brackets, but I keep getting syntax errors whatever way I try it. Is this possible or am I being stupid?
try that :
$data = file_get_contents ($row['url']);
This question already has answers here:
How do I ignore a moved-header with file_get_contents in PHP?
(3 answers)
Closed 8 years ago.
I am trying to get contents of a Website with simple html DOM as follows:
<?php
include_once('../simple_html_dom.php');
$html = file_get_html('http://www.opaltransfer.com/en');
echo($html);
?>
When i run this on my localhost everything works fine, However when i try to run it on a remote server i am getting
Found
The document has moved here.
Why? and what can i do to get it to work? Thanks in advance
You're missing a / at the end of the URL.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
php headers already sent error
I have tried every thing to solve it, but this thig just wont go away.
Here is what I'm doing
if($query)
{
header("location:cool.php");
exit();
}
even though $query is executed, an issue with header.
thanks.
ANY output will need headers sent, so any output will get you this error.
Common problems:
whitespace (e.g. before the <?php )
errors / exceptions
debugging echos/var_dumps
warnings from php (deprecated)
You will get that error of you have any (I mean ANY) output beforehand
Ensure that $query is not outputting any data, other wise you'll get your error.
If not check to make sure NO data is being output before hand.