1

i am trying to add data into xml,using php code,but it doesn't appear to be working properly,as the page shows parts of the code,so mainly it's not being parsed,and i can't seem to find a solution to that,any help? the parameter of the createElement function is not being parsed correctly,or at all

if (isset($_REQUEST['ok']))
 {
     $xml= new DOMDocument("1.0","UTF-8");
     $xml->load("Dbase.xml");
     $root=$xml->getElementsByTagName("Database")->item(0);
     $Movie=$xml->createElement("Movie");
     $title=$xml->createElement("Title","$_REQUEST['title']");
     $cast=$xml->createElement("Cast","$_REQUEST['cast']");
     $dir=$xml->createElement("Director","$_REQUEST['director']");
     $prod=$xml->createElement("Producer","$_REQUEST['prod']");
     $syn=$xml->createElement("Synopsis","$_REQUEST['syn']");
     $Movie->appendChild("$title");
     $Movie->appendChild("$cast");
     $Movie->appendChild("$dir");
     $Movie->appendChild("$prod");
     $Movie->appendChild("$syn");
     $root->appendChild("$Movie");
     $xml->save("Dbase.xml");
 }

Here is a screenshot of what the result looks like

MrRobot
  • 583
  • 5
  • 17
  • your not running that code through php –  Jan 27 '16 at 23:00
  • 1
    there are syntax errors where you include `$_REQUEST['var']` in quotes without using curly braces – Professor Abronsius Jan 27 '16 at 23:05
  • @Dagon it isn't duplicate question as the other answers did not apply to my problem,i checked them,and why am i not running it through php?it has .php extension,i have the '' sections in my code,and all the config mentionned in the other topic,is valid – MrRobot Jan 27 '16 at 23:28
  • @RamRaideractually you are right,what you said was right it is the solution to my problem,can you please provide an explanation why it worked only that way? – MrRobot Jan 27 '16 at 23:28
  • we see the source, its not running via php, it is a duplicate, check all the solutions on the listed dupe. –  Jan 27 '16 at 23:29
  • those lines were flagged up in dreamweaver which is why i mentioned it – Professor Abronsius Jan 27 '16 at 23:32
  • @Dagon the proof what you are saying is wrong,is that it worked by adjusting only the brackets as RamRaider said – MrRobot Jan 27 '16 at 23:33
  • 1
    the absence of the brackets would result in a parse error, not the display of the source –  Jan 27 '16 at 23:41
  • @Dagon i understand,but still the data is not sent to the xml file,it just doesn't show the previous error messages,now it doesn't simply perform the data transmission to the xml file,and i reassure i checked all points in the other topic,all of them are valid – MrRobot Jan 27 '16 at 23:51

0 Answers0