PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Sepai
Forum Newbie
Posts: 3 Joined: Wed Jul 11, 2007 3:54 pm
Post
by Sepai » Wed Jul 11, 2007 4:08 pm
I am brand new to PHP but would like to create a form in an HTML page that will use the data entered into it to display an XML file.
I fould this tutorial:
http://www.topxml.com/php_simplexml/default.asp
but didnt really understand it and was getting error messages when trying to use it:
Parse error: syntax error, unexpected T_STRING in /xml/php/employee.php on line 8
Code: Select all
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
Does anyone know of another tutorial is have any pointers to get me started?
Thanks.
Last edited by
Sepai on Wed Jul 11, 2007 4:33 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 11, 2007 4:10 pm
Can you posted the lines before that line too?
Sepai
Forum Newbie
Posts: 3 Joined: Wed Jul 11, 2007 3:54 pm
Post
by Sepai » Wed Jul 11, 2007 4:12 pm
Yep sure:
Code: Select all
if(isset($_POST['create_employee'])){
echo "Employee Data Posted";
$xmlfileName = $_POST['xmlfileName'];
$empName = $_POST['empName'];
$empAddress = $_POST['empAddress'];
$empSSN = $_POST['empSSN'];
$empCompany = $_POST['empCompany'];
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$rootELementStart = "<employee>";
$rootElementEnd = "</employee>";
$xml_doc= $xml_dec;
$xml_doc .= $rootELementStart;
$xml_doc .= "<employeename>";
$xml_doc .= $empName;
$xml_doc .= "</employeename>";
$xml_doc .= "<employeeaddress>";
$xml_doc .= $empAddress;
$xml_doc .= "</employeeaddress>";
$xml_doc .= "<SSN>";
$xml_doc .= $empSSN;
$xml_doc .= "</SSN>";
$xml_doc .= "<company>";
$xml_doc .= $empCompany;
$xml_doc .= "</company>";
$xml_doc .= $rootElementEnd;
$default_dir = "xml_files/";
$default_dir .= $xmlfileName .".xml";
$fp = fopen($default_dir,'w');
$write = fwrite($fp,$xml_doc);
Thats the whole php file.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 11, 2007 4:21 pm
Outside of a missing closing brace for the if, I don't see any syntax errors.