I have a PHP script in which you can add text in some fields. The PHP script adds the text which are in the fields in 2 xml files. It is working good, but if the xml is getting too big (7000 lines is my xml), it can't write anymore.
I changed my php.ini into this
max_execution_time = 300
max_input_time = 900
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 512M
So is this problem caused by the php.ini or in PHP file. The script will only work when I delete a piece of xml code.
here is php
ini_set('default_charset', 'utf-8');
if(isset($_POST['post']) && $_POST['post']=='true')
{$file1Content = '<?xml version="1.0"?>
<channels>';
for($j=0; $j < $_POST['total1']; $j++)
{if(isset($_POST['checkbox1'.$j]) && $_POST['checkbox1'.$j]=="on")
{$file1Content .="
<channel>
<title>".$_POST['checkbox1'.$j.'_title']."</title>
<img>".$_POST['checkbox1'.$j.'_img']."</img>
<info>".$_POST['checkbox1'.$j.'_info']."</info>
<url>".$_POST['checkbox1'.$j.'_url']."</url>
</channel>";}}
$file1Content .= "</channels>";
$fileHandle = fopen($file1,"w");
fwrite ($fileHandle, $file1Content);
fclose ($fileHandle);
if (isset($_POST['post']) && $_POST['post']=="true" && $_POST['title']!='')
$fileContent = file_get_contents($file1);
$fileNewXml = "
<title>".$_POST['title']."</title>
<img>".$_POST['image']."</img>
<info>".$_POST['info']."</info>
<url>".$_POST['url']."</url>";
//Place elemnt in the right place
$pos=$_POST['pos1'];
$allTags=explode("<channel>",$fileContent,strlen($fileContent));
if(count($allTags)==1) //if file is empty
{$fileNewContent='<?xml version="1.0"?>
<channels>
<channel>"'.$fileNewXml.'</channel></channels>';}
$fileHandle = fopen($file1,"w");
fwrite ($fileHandle, $fileNewContent);
fclose ($fileHandle);
<?php
$content= file_get_contents($file1);
$arr = simplexml_load_string($content);
$i=1;
foreach ($arr as $element)
{
echo "<option value='$i'>$element->title</option>";
$i++;
}
?>