Ruko Posted July 9, 2011 Share Posted July 9, 2011 Is there any way to turn XML data into PHP variables. I tried this code $xml = simplexml_load_file("../inc/xml/style.xml); $result = $xml->xpath("styleinfo"); // lets make sql querys to upload the XML style info to the database $name = $result[0]->name; $desc = $result[0]->description; $copyright = $result[0]->copyright; $version = $result[0]->version; $designer = $result[0]->designer; mysql_query("INSERT INTO styles (stylename, styledescription, stylecopyright, version, designer) VALUES ('$name', '$desc', '$copyright', '$version', '$designer')") or die(mysql_error()); and the XML data outputs as blank. Help pls Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/ Share on other sites More sharing options...
QuickOldCar Posted July 9, 2011 Share Posted July 9, 2011 forgot a double quote $xml = simplexml_load_file("../inc/xml/style.xml"); Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/#findComment-1240346 Share on other sites More sharing options...
silkfire Posted July 9, 2011 Share Posted July 9, 2011 Before adding it to the database echo it out and see what you get. Could you post some sample of the XML? Link to comment https://forums.phpfreaks.com/topic/241461-xml-to-php-variables/#findComment-1240454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.