0

I'm getting this weird error in my Zend application with this piece of code:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'www.xyz.com/ab.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);      

if (!isset($location->country)) {
$location = new Zend_Session_Namespace('location');
$xml = new SimpleXMLElement($data);
$location->city=$xml->City;
}

This is the error, I get:

Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()

When I remove that code everything works fine. Any idea ??

Edit: On further debugging I found that the error was not because of the curl code - it was ocuring later when I was assigning $location->city=$xml->City; But when I change that line to $location->city=''.$xml->City.''; It starts working..........this is driving me crazy !!!!

2 Answers 2

1

Not quite sure what your issue is, but I can tell you that Zend_Http_Client is very nice and robust and it has support for multiple adapters including CURL.

Example:

$http = new Zend_Http_Client(
  'url',
   $this->options
);
$response = $http->request();

http://framework.zend.com/manual/en/zend.http.html

0
0

Your new Zend_Session_Namespace('location'); call will try to start a new session but apparently one has already been started without using Zend_Session calls, and thus it throws an exception. So check the rest of your code (and php.ini) to find out where you start that session (it could be because session.auto_start=1 in php.ini, or a session_start() call somewhere) and fix it as you see fit...

1
  • Thanks for your reponse - Thats what I thought and my search on google also led me to same conclusion - but see my edit section above - when I make that change everything starts working fine - It seems weird to me as to what the connection is
    – Gublooo
    May 8, 2010 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.