Jump to content

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);
Link to comment
https://forums.phpfreaks.com/topic/13658-xml_parser_create-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.