dc2007 Posted June 26, 2012 Share Posted June 26, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/ Share on other sites More sharing options...
requinix Posted June 26, 2012 Share Posted June 26, 2012 Try with the LIBXML_PARSEHUGE option. Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357190 Share on other sites More sharing options...
dc2007 Posted June 26, 2012 Author Share Posted June 26, 2012 can you explain please or give me an example with the code i added thank you as i dont know what to do with that never used libxml. Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357199 Share on other sites More sharing options...
dc2007 Posted June 26, 2012 Author Share Posted June 26, 2012 really need help with this Urgent if possible...thanks Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357256 Share on other sites More sharing options...
requinix Posted June 27, 2012 Share Posted June 27, 2012 You can pass it as an argument to simplexml_load_string. Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357306 Share on other sites More sharing options...
dc2007 Posted June 27, 2012 Author Share Posted June 27, 2012 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' Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357334 Share on other sites More sharing options...
requinix Posted June 27, 2012 Share Posted June 27, 2012 I gave you link with the expectation that you would click it and read the page you were brought to. Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357339 Share on other sites More sharing options...
dc2007 Posted June 27, 2012 Author Share Posted June 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/264810-php-issue-please-help/#findComment-1357348 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.