Jump to content

Archived

This topic is now archived and is closed to further replies.

snowdog

xml_parser_create problem

Recommended Posts

We can run this code from a browser and it works fine. Once we try and run it from a cron, it exits the script on this line.

                            $xml_parser = xml_parser_create();

Have written a log file before and after the area and have determined this is where it is crashing. The coding is sending information out to an external server and getting information back. If I execute the code from the browser no problems but not from the cron. Any ideas??

Here is some of the code below

Thanks Snowdog

// do the curl stuff
                  $ch = curl_init();    // initialize curl handle
                  curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
                  curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 30s
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
                  $curl_result = curl_exec($ch); // run the whole process
                  if (curl_errno($ch))
                  {
                    $error_message = curl_error($ch)." on client_id $row_billing->client_id\r\n";
                    fwrite($handle,$error_message);
                    $email_error_message .= $error_message;
                  }
                  else
                  {
                    curl_close($ch);
                  }

                  // parse the xml return
                  $xml_parser = xml_parser_create(); [color=red]//****** THIS IS WEHRE IT IS CRASHING ******//[/color]
                  xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
                  xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
                  xml_parse_into_struct($xml_parser, $curl_result, $vals, $index);
                  xml_parser_free($xml_parser);

                  // get some of the vars from the parsed xml Array
                  $status = $vals['4']['value'];
                  $start = substr($vals['1']['value'],0,19);
                  $end = substr($vals['1']['value'],23,5);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.