I am using this code
$userName=$this->input->post('user');
$password=$this->input->post('pass');
$lineNumber=$this->input->post('line');
$to= $this->input->post('Receiver');
$text=$this->input->post('messageBody');;
$client= new SoapClient('http://n.sms.ir/ws/SendReceive.asmx?wsdl');
$parameters['userName'] = $userName;
$parameters['password'] = $password;
$parameters['mobileNos'] = array(doubleval($to));
$parameters['messages'] = array($text);
$parameters['lineNumber'] = $lineNumber;
$parameters['sendDateTime'] = date("Y-m-d")."T".date("H:i:s");
print_r($client->SendMessageWithLineNumber($parameters));
But this happens
A PHP Error was encountered
Severity: Warning
Message:
SoapClient::SoapClient(http://n.sms.ir/ws/SendReceive.asmx?wsdl):
failed to open stream: Connection timed out
Filename: views/sms.php
Line Number: 19
and
A PHP Error was encountered
Severity: Warning
Message: SoapClient::SoapClient(): I/O warning : failed to load
external entity "http://n.sms.ir/ws/SendReceive.asmx?wsdl"
Filename: views/sms.php
Line Number: 19
Does anyone know what's wrong?
go to file system/core/CodeIgniter.php and increase set_time_limit by default it set 300
if (function_exists("set_time_limit") == TRUE AND #ini_get("safe_mode") == 0)
{
#set_time_limit(300);//increase it according to your requirement
}
Related
<?php
$get = file_get_contents("https://duckduckgo.com/i.js?q=love&s=1");
$decode = json_decode($get, TRUE);
foreach($decode['results'] as $res) {
echo "".$res['image']."";
}
?>
Nothing happens. What's wrong?
Warning: file_get_contents(https://duckduckgo.com/i.js?q=love&s=1) [function.file-get-contents]: failed to open stream: No such file or directory in /home01/rfep/nzfrka/home/mydomain/myfeed/sssfi.php on line 2
failed to open stream
Warning: Invalid argument supplied for foreach() in /home01/rfep/nzfrka/home/mydomain/myfeed/sssfi.php on line 4
Needs to get location details for the latitude and longitude,
It just work in other server - functioning correctly, but trying with client dev server getting error, i have tried with this about 4 hours - till didn't get the result. assist would be helpful.
Here is my code:
public function index() {
echo $this->getLocation('39.2323', '-97.3828');
}
function getLocation($lat, $long) {
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" . trim($lat) . "," . trim($long) . "&sensor=false";
$json = #file_get_contents($url);
$data = json_decode($json);
$status = $data->status;
$address = '';
if ($status == "OK") {
$address = $data->results[0]->formatted_address;
}
return $address;
}
Am getting the error like below:
A PHP Error was encountered Severity: Warning Message:
file_get_contents(http://maps.googleapis.com/maps/api/geocode/json?latlng=39.2323,-97.3828&sensor=false)
[function.file-get-contents]: failed to open stream: Connection timed
out
Filename: webservice/Test.php Line Number: 17
Backtrace:
File:
/home/colanful/public_html/hoa/application/controllers/webservice/Test.php
Line: 17 Function: file_get_contents
File:
/home/colanful/public_html/hoa/application/controllers/webservice/Test.php
Line: 12 Function: getaddress
File: /home/colanful/public_html/hoa/index.php Line: 292 Function:
require_once
Looks like you need to change an ini setting on the clients dev server.
From #Aillyn's answer:
The setting you are looking for is allow_url_fopen.
You have two ways of getting around it without changing php.ini, one of them is to use fsockopen(), and the other is to use cURL.
I recommend using cURL over file_get_contents() anyways, since it was built for this.
I am using PHP with MySQL to pull programs, courses, etc. on 2003 box with PHP 5.2. I am transferring my site to a new 2008 box with PHP 5.4 (because of injection exploits on database). My data still pulls to my site (programs, courses etc) from my new server.
The issue is I have a page that is for login and will not load (HTTP 500 error). I have traced back to section of code that kicks out and believe it is the session_start(). I know in 5.3 it changed and will now return false if it fails to start instead of the previous true.
I've tried echoing out what loads line by line with each variable since I can compare it with the two versions. I've tried starting the session at the beginning. Ending it before my code, etc. It seems simple, but I haven't got it to work yet.
Here's the beginning of my page "login-inc-header.php":
<?php
if(!isset($session_started)) $session_started = session_start();
// avoids duplicate pstings
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
ini_set("display_errors", "1");
if(!isset($requires)) $requires = "User";
include_once("includes/handleLogin.php");
include_once("../includes_app/db_settings.php");
?>
If I remove this block, The page will load just without my login boxes. Pages works perfect in version 5.2. Ideas?
My db_settings:
<?php
//$site_root = "/var/www/html/";
$site_root = "C:\\Inetpub\\wwwroot\\"; //changed 12-13-13 for new server
//$site_root = substr($_SERVER['PATH_TRANSLATED'], 0, (-1 * strlen($_SERVER['PATH_INFO'])));
$site_url = "http://10.20.251.60/";
include_once($site_root."includes_app/adodb/adodb.inc.php");
$db =& ADONewConnection('mysql');
$db->Connect("localhost", "####", "####", "####");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
// for mysql only...make sure we are NOT in strict mode
$db->Execute("SET sql_mode=''");
$tblprefix = "";
$extraFieldLabHours = true;
$extraFieldOBIHours = true;
$extraFieldsPrereqCoreq = true;
$extraFieldProgramRequirements = true;
$maxCourseCodeLength = 4;
$maxCoursePrefixLength = 4; // 11-05-10 added this line to fix prefix length
$exportReport[$site_url.'includes_app/html_word_export.php'] = "Export for Microsoft Word 2007";
$exportReport[$site_url.'includes_app/html_rtf_export.php'] = "Export for Adobe InDesign CS2";
$exportReport[$site_url.'directory/print.php'] = "Export Directory to HTML";
$sysadmin_email = "gntc#gntc.edu";
$extraModuleEmployeeDirectory = true;
$extraModuleCampusAlert = true;
$extraFieldAtAGlance = true;
$areas = array();
$configAreasResult = $db->Execute("SELECT dbName, displayName FROM ".$tblprefix."areas ORDER BY sequence");
while($configRow = $configAreasResult->fetchRow()) $areas[$configRow['dbName']] = $configRow['displayName'];
$program_types = array();
$configProgramTypesResult = $db->Execute("SELECT dbName, displayName FROM ".$tblprefix."program_types ORDER BY sequence");
while($configRow = $configProgramTypesResult->fetchRow()) $program_types[$configRow['dbName']] = $configRow['displayName'];
$extraFieldCampus = array();
$configCampusesResult = $db->Execute("SELECT displayName FROM ".$tblprefix."campuses ORDER BY sequence");
while($configRow = $configCampusesResult->fetchRow()) $extraFieldCampus[] = $configRow['displayName'];
$extraFieldEmployeeOfficeHours = true;
$extraFieldEmployeeBio = true;
$extraFieldEmployeePicture = true;
$extraFieldFoptNumRequirements = true;
$alternateTitleGeneralCoreCourses = "General Core Curriculum";
$alternateTitleOccupationalCourses = "Occupational Curriculum";
$extraModuleCampusAlert = true; // added on 3-10-10 to make campus alert feature work
$alternateTitleEmployeeEducation = "Credentials"; $showBannerID = true;
$deeperMenus = true;
$importModules = array();
$importModules['import_courses_xml.php'] = "Courses XML";
$importModules['import_employees_xml.php'] = "Employees XML";
$extraModuleDivisions = true;
$gntc_local_upload_dir = $site_root."uploads/";
$gntc_web_upload_dir = $site_url."uploads/";
$exportReport[$site_url.'includes_app/phone_sheet_csv.php'] = "Phone Sheet CSV";
?>
Log File:
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(includes/handleLogin.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\login\includes\header.php on line 8
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(): Failed opening 'includes/handleLogin.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\login\includes\header.php on line 8
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(../includes_app/db_settings.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\login\includes\header.php on line 9
[16-Jan-2014 21:17:46 UTC] PHP Warning: include_once(): Failed opening '../includes_app/db_settings.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\login\includes\header.php on line 9
[16-Jan-2014 21:17:46 UTC] PHP Notice: Undefined variable: title in C:\inetpub\wwwroot\login\includes\header.php on line 16
[16-Jan-2014 21:17:46 UTC] PHP Notice: Undefined variable: title in C:\inetpub\wwwroot\login\includes\header.php on line 159
I noticed that this referenced PEAR, which in not installed by default like older versions. Could this be the issue?
You have put this as your site root
$site_root = "C:\\Inetpub\\wwwroot\\";
Try putting
$site_root = "http://yourhost/folder_name/"
If i push a string which doesn't exist or misspelled to function benzer($ilk_artist) i am getting errors bottom. Whether i push a valid artist name or not variable $completeurl is always defined. So i can't put if($completeurl) I think i should control whether $completeurl is valid before simplexml_load_file($completeurl). Do you have an idea that how i can do it?
function benzer($ilk_artist)
{
$completeurl = 'http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist='.trim($ilk_artist).'&api_key='.LASTFM_APP_ID;
$completeurl = urlencode($completeurl);
$xml = simplexml_load_file($completeurl);
if(!$xml)
{
return false;
}
$artists = $xml->similarartists->artist;
$length = count($artists);
for ($i = 0; $i < $length; $i++) {
$artistname[$i] = $artists[$i]->name;
}
return simplexml_kurtul($artistname);
}
errors:
[17-Dec-2012 11:43:33] PHP Warning: simplexml_load_file(http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=tgyu+6uh6n&api_key=APIKEY) [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
in /home6/.../public_html/.../functions/fns.php on line 102
[17-Dec-2012 11:43:33] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: I/O warning : failed to load external entity "http%3A%2F%2Fws.audioscrobbler.com%2F2.0%2F%3Fmethod%3Dartist.getsimilar%26artist%3Dtgyu+6uh6n%26api_key=APIKEY0" in /home6/.../public_html/.../functions/fns.php on line 102
What about not printing out the warnings by adding '#'?
$xml = #simplexml_load_file($completeurl);
if(!$xml)
{
return false;
}
i load file from server:
$url = 'http://www.sample.com/test.xml';
$xml = simplexml_load_file($url);
And if servers is close i get error:
Warning: simplexml_load_file() [function.simplexml-load-file]: php_network_getaddresses: getaddrinfo failed:...
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity
how to check if the file is reached?
From the manual page for simplexml_load_file
Returns an object of class SimpleXMLElement with properties containing the data held within the XML document. On errors, it will return FALSE.
which means you can do
$url = 'http://www.sample.com/test.xml';
$xml = simplexml_load_file($url);
// check what was returned
if(FALSE === $xml) {
echo 'could not open file';
}