PHP file_get_contents not working - php

i am having a problem with PHP file_get_contents.
$html = file_get_html($csfd_link);
Writes an error:
Warning: file_get_contents() [function.file-get-contents]:
php_network_getaddresses: getaddrinfo failed: Name or service not
known in /home/vo003500/www_root/admin/simple_html_dom.php on line 76
Warning: file_get_contents(http://www.example.com/)
[function.file-get-contents]: failed to open stream:
php_network_getaddresses: getaddrinfo failed: Name or service not
known in /home/vo003500/www_root/admin/simple_html_dom.php on line 76
I do not know what it is. The server is allow_url_fopen ON
Thanks
Edit:
Until now it worked, but the last 2 weeks not working...

It looks like your suffering from DNS (Domain Name Service) resolution error. Make sure there is a proper DNS server entry in /etc/resolv.conf.

Related

error in file get contents and var_dump

i use this code:
<?php
$token="683911895:AAGGVHW_RdP9h4dfvXYPABJe-RGdfyj125g";
$url="https://api.telegram.org/bot" . $token . "/getupdates";
$content=file_get_contents($url);
var_dump ($content);
?>
but it have 2 errors:
1:
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\wamp\www\tbot.php on line 5
2:
Warning: file_get_contents(https://api.telegram.org/bot683911895:AAGGVHW_RdP9h4dfvXYPABJe-RGdfyj125g/getupdates): failed to open stream: php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\wamp\www\tbot.php on line 5
and telegram is ban in my country
check php settings "allow_url_fopen = On"
check the usage here http://www.php.net/manual/en/function.file-get-contents.php
if it still will not connect then you have an issue with the URL or DNS on your server.

Is there any way to check .PEM file is Valid or not in iOS?

I have created production AdHoc .pem files. I have followed this steps:
By using This Link
I created .PEM file and i checked does this valid or not by using following command like:
$php simplepush.php
but i am getting an error like::
Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Users/mac-jarc/Desktop/SimplePush/simplepush.php on line 21
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known) in /Users/mac-jarc/Desktop/SimplePush/simplepush.php on line 21
Failed to connect: 0 php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
But in my PHP developer said it's a .PEM file mistake . I tought it's not(Because i am very sure my .PEM file is perfect) and i suggested to him like it's a server ports issue
Can you please help me out regarding this:: How would i check does my .PEM file is valid or not.
Here is my php code:

PHP stream_socket_client() Warning

I am building a new WordPress site for a client and all of a sudden today I am seeing this error at the top of the screen. I have never seen this before. Any ideas what could be causing this to happen now? Also how to fix it?
Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/wp-includes/class-http.php on line 787
Warning: stream_socket_client(): unable to connect to tcp://www.MY-DOMAIN.com:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /var/www/wp-includes/class-http.php on line 787
Not sure if you are using a VM but when I had this error I resolved it by adding an entry to my hosts file in my vagrant machine that pointed back to localhost.
127.0.0.1 www.MY-DOMAIN.com

PHP - Installing Composer - failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known

I am attempting to use the Composer Dependency Manager for PHP, but I am experiencing the following issue when I use the Composer-Setup.exe (Win32 installer).
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
Download failed: php_network_getaddresses: getaddrinfo failed: No such host is known.
failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
The download failed repeatedly, aborting.`
I followed the advice on several other stackoverflow threads for that error, and I've checked some other forums. In my php.ini, I have made sure I have the following options:
allow_url_fopen = On
allow_url_include = On
extension=php_openssl.dll
I also tried the manual installation of Composer, which asks you to execute:
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
I get the same error from that. However, If I remove "/installer", it can retrieve the source. I have verified that that the "/installer" URL works. What configuration could cause this behavior? I'm running PHP 5.4 on 32-bit Windows 7.
Thanks,
Andrew
This issue was actually the proxy variables. While the console was picking up the changes, PHP required a system restart to pick it up. So unsetting the environment variables and restarting allowed the Composer installer to retrieve the required files. Thanks Seldaek for your recommendation to check the proxy.
Solution 1
Ensure you have connectivity try ping www.google.com
Solution 2
- Remove Proxy settings ,they could be ones causing it,if outside a corporate network
Solution 3
Add the corporate proxy setting if on a corporate network
set http_proxy=http://your_proxy:your_port
set http_proxy=http://username:password#your_proxy:your_port
set https_proxy=https://your_proxy:your_port
set https_proxy=https://username:password#your_proxy:your_port
mysqli_connect('root','', 'localhost', 'people');
You are passing root in as hostname.
try this
mysqli_connect('localhost','root', '', 'people');
this will connect to localhost with username root passwoord "" and default database people.
maybe better to change localhost with 127.0.0.1

Connection to my sql data base

First, let me note that the connection infomation is not the correct info. I made a database on 1and1 and I want to connect to it from the web. I am not getting the syntax correct here, can someone point me in the right direction?
Here is what I have:
//connect to DB
$dbc=mysql_connect('http://db232154114.db.1and1.com','db232154114','password');
mysql_select_db('tableName',$dbc)
Here are the errors that I am getting:
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses:
getaddrinfo failed: No such host is known. in
C:\xampp\htdocs\ciss225Testing\homework\final_process.php on line 35
Warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses:
getaddrinfo failed: No such host is kn (trying to connect via tcp://http:3306) in
C:\xampp\htdocs\ciss225Testing\homework\final_process.php on line 35
Warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses:
getaddrinfo failed: No such host is known. in
C:\xampp\htdocs\ciss225Testing\homework\final_process.php on line 35
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in
C:\xampp\htdocs\ciss225Testing\homework\final_process.php on line 37
Try to replace http://db232154114.db.1and1.com/ with IP address of SQL server you're connecting to
Remove http:// and enable remote MySQL connections from your server's cPanel or so
your connection string is not right. get rid of the "http://" stuff; that is not part of the db server's hostname.

Categories