Jump to content

PHP issue please help..


dc2007

Recommended Posts

Hi i have a little bit of php code and its uses simple xml to parse file uploads

 

but it seems to work fine with

 

<?xml version="1.0" encoding="UTF-8"?> when its parsed tidly

 

0but errors out on <?xml version="1.0" encoding="iso-8859-1" ?>

 

the code is

 

function pieceslisting($where, $id) {

    $filecontent = file_get_contents($where);
    $xml = simplexml_load_string($filecontent) or die ("Unable to load XML file!"); 
    $nzbpiece = 0;
    foreach($xml->{"file"} as $nfile) {
	$nsubject = (string) trim($nfile['subject']);
	$ndate = 0 + trim($nfile['date']);
        $nposter = (string) trim($nfile['poster']);
        $nposter = sqlesc($nposter);

        // To find num of segments in subject:
        $nsubjsegs = 0 + subj_seg($nsubject);

        // To find out if Par or not
        $npar = sqlesc(stristr($nsubject, "par2")?0:1);
	$nsfv = sqlesc(stristr($nsubject, "sfv")?0:1);
	$nnfo = sqlesc(stristr($nsubject, "nfo")?0:1);
	$navi= sqlesc(stristr($nsubject, "avi")?0:1);
        //$nr = sqlesc(stristr($nsubject, 'r')?0:1000);
	$nrar = sqlesc(stristr($nsubject, "rar")?0:1);

        $nsubject = sqlesc($nsubject);                  

        $groups = array();
        foreach($nfile->groups->group as $group) {
              $groups[] = (string) trim($group);
        }
        $ngroups = sqlesc(serialize($groups));
        $nsegcount = 0;
        $nsize = 0;

        foreach($nfile->segments->segment as $segment) {
              $nbytes = 0 + trim($segment['bytes']);
              $nsize += $nbytes;
              $nsegcount++; 
        }

        $query = mysql_query("UPDATE " . TABLE_PREFIX . "nzbpiecelist SET piece_poster = $nposter, piece_date = $ndate, piece_subject = $nsubject, piece_groups = $ngroups, piece_size = $nsize, piece_segments = $nsegcount, piece_subjseg = $nsubjsegs, piece_par = $npar, piece_sfv = $nsfv, piece_nfo = $nnfo, piece_avi = $navi, piece_rar = $nrar WHERE nzb = $id AND nzb_piece = $nzbpiece");

        $nzbpiece++;
    }
    unset ($filecontent, $nzbpiece, $xml, $nposter, $ndate, $nsubject, $ngroups, $nsize, $nsegcount, $nsubjsegs, $npar, $nsfv, $nnfo, $navi, $nrar);
}

 

i upload a file and it come up with erros like this

 

Warning: simplexml_load_string() [function.simplexml-load-string]: (null)Entity: line 27881: parser error : out of memory

 

but i have memory_limit = 500M and im running php5.4.4 and also tried on 5.3.13.

 

can any one help thanks.

Link to comment
Share on other sites

i put

 

simplexml_load_string($filecontent,'LIBXML_PARSEHUGE');

 

and get error

 

Warning: simplexml_load_string() expects parameter 2 to be a class name derived from SimpleXMLElement, 'LIBXML_PARSEHUGE'

Link to comment
Share on other sites

hi i have looked around that site i cant see any example with LIBXML_PARSEHUGE in it but also it states 

 

Only available in Libxml >= 2.7.0 (as of PHP >= 5.3.2 and PHP >= 5.2.12)

 

im running PHP 5.3.13 and 5.4.4 can you please give me an example of how to implement it into the original code.. thanks

 

Link to comment
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.